Git fork

Merge branch 'kn/for-each-ref-skip-updates'

Code clean-up.

* kn/for-each-ref-skip-updates:
ref-filter: use REF_ITERATOR_SEEK_SET_PREFIX instead of '1'
t6302: add test combining '--start-after' with '--exclude'
for-each-ref: reword the documentation for '--start-after'
for-each-ref: fix documentation argument ordering
ref-cache: use 'size_t' instead of int for length

+33 -11
+7 -6
Documentation/git-for-each-ref.adoc
··· 7 7 8 8 SYNOPSIS 9 9 -------- 10 - [verse] 11 - 'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl] 10 + [synopsis] 11 + git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl] 12 12 [(--sort=<key>)...] [--format=<format>] 13 - [--include-root-refs] [ --stdin | <pattern>... ] 14 - [--points-at=<object>] 13 + [--include-root-refs] [--points-at=<object>] 15 14 [--merged[=<object>]] [--no-merged[=<object>]] 16 15 [--contains[=<object>]] [--no-contains[=<object>]] 17 - [--exclude=<pattern> ...] [--start-after=<marker>] 16 + [(--exclude=<pattern>)...] [--start-after=<marker>] 17 + [ --stdin | <pattern>... ] 18 18 19 19 DESCRIPTION 20 20 ----------- ··· 114 114 deleted, modified or added between invocations. Output will only yield those 115 115 references which follow the marker lexicographically. Output begins from the 116 116 first reference that would come after the marker alphabetically. Cannot be 117 - used with general pattern matching or custom sort options. 117 + used with `--sort=<key>` or `--stdin` options, or the _<pattern>_ argument(s) 118 + to limit the refs. 118 119 119 120 FIELD NAMES 120 121 -----------
+1 -1
builtin/for-each-ref.c
··· 45 45 OPT_GROUP(""), 46 46 OPT_INTEGER( 0 , "count", &format.array_opts.max_count, N_("show only <n> matched refs")), 47 47 OPT_STRING( 0 , "format", &format.format, N_("format"), N_("format to use for the output")), 48 - OPT_STRING( 0 , "start-after", &filter.start_after, N_("start-start"), N_("start iteration after the provided marker")), 48 + OPT_STRING( 0 , "start-after", &filter.start_after, N_("start-after"), N_("start iteration after the provided marker")), 49 49 OPT__COLOR(&format.use_color, N_("respect format colors")), 50 50 OPT_REF_FILTER_EXCLUDE(&filter), 51 51 OPT_REF_SORT(&sorting_options),
+3 -2
ref-filter.c
··· 3254 3254 3255 3255 if (filter->start_after) 3256 3256 ret = start_ref_iterator_after(iter, filter->start_after); 3257 - else if (prefix) 3258 - ret = ref_iterator_seek(iter, prefix, 1); 3257 + else 3258 + ret = ref_iterator_seek(iter, prefix, 3259 + REF_ITERATOR_SEEK_SET_PREFIX); 3259 3260 3260 3261 if (!ret) 3261 3262 ret = do_for_each_ref_iterator(iter, fn, cb_data);
+3 -2
refs/ref-cache.c
··· 498 498 * indexing to each level as needed. 499 499 */ 500 500 do { 501 - int len, idx; 501 + int idx; 502 + size_t len; 502 503 int cmp = 0; 503 504 504 505 sort_ref_dir(dir); 505 506 506 507 slash = strchr(slash, '/'); 507 - len = slash ? slash - refname : (int)strlen(refname); 508 + len = slash ? (size_t)(slash - refname) : strlen(refname); 508 509 509 510 for (idx = 0; idx < dir->nr; idx++) { 510 511 cmp = strncmp(refname, dir->entries[idx]->name, len);
+19
t/t6302-for-each-ref-filter.sh
··· 712 712 test_cmp expect actual 713 713 ' 714 714 715 + test_expect_success 'start after, with exclude pattern' ' 716 + cat >expect <<-\EOF && 717 + refs/tags/annotated-tag 718 + refs/tags/doubly-annotated-tag 719 + refs/tags/doubly-signed-tag 720 + refs/tags/foo1.10 721 + refs/tags/foo1.3 722 + refs/tags/foo1.6 723 + refs/tags/four 724 + refs/tags/one 725 + refs/tags/signed-tag 726 + refs/tags/three 727 + refs/tags/two 728 + EOF 729 + git for-each-ref --format="%(refname)" --start-after=refs/odd/spot \ 730 + --exclude=refs/tags/foo >actual && 731 + test_cmp expect actual 732 + ' 733 + 715 734 test_expect_success 'start after, last reference' ' 716 735 cat >expect <<-\EOF && 717 736 EOF