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 lengthmaint
commit
10be1c41bc
|
|
@ -7,14 +7,14 @@ git-for-each-ref - Output information on each ref
|
|||
|
||||
SYNOPSIS
|
||||
--------
|
||||
[verse]
|
||||
'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]
|
||||
[synopsis]
|
||||
git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl]
|
||||
[(--sort=<key>)...] [--format=<format>]
|
||||
[--include-root-refs] [ --stdin | <pattern>... ]
|
||||
[--points-at=<object>]
|
||||
[--include-root-refs] [--points-at=<object>]
|
||||
[--merged[=<object>]] [--no-merged[=<object>]]
|
||||
[--contains[=<object>]] [--no-contains[=<object>]]
|
||||
[--exclude=<pattern> ...] [--start-after=<marker>]
|
||||
[(--exclude=<pattern>)...] [--start-after=<marker>]
|
||||
[ --stdin | <pattern>... ]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
|
@ -114,7 +114,8 @@ TAB %(refname)`.
|
|||
deleted, modified or added between invocations. Output will only yield those
|
||||
references which follow the marker lexicographically. Output begins from the
|
||||
first reference that would come after the marker alphabetically. Cannot be
|
||||
used with general pattern matching or custom sort options.
|
||||
used with `--sort=<key>` or `--stdin` options, or the _<pattern>_ argument(s)
|
||||
to limit the refs.
|
||||
|
||||
FIELD NAMES
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ int cmd_for_each_ref(int argc,
|
|||
OPT_GROUP(""),
|
||||
OPT_INTEGER( 0 , "count", &format.array_opts.max_count, N_("show only <n> matched refs")),
|
||||
OPT_STRING( 0 , "format", &format.format, N_("format"), N_("format to use for the output")),
|
||||
OPT_STRING( 0 , "start-after", &filter.start_after, N_("start-start"), N_("start iteration after the provided marker")),
|
||||
OPT_STRING( 0 , "start-after", &filter.start_after, N_("start-after"), N_("start iteration after the provided marker")),
|
||||
OPT__COLOR(&format.use_color, N_("respect format colors")),
|
||||
OPT_REF_FILTER_EXCLUDE(&filter),
|
||||
OPT_REF_SORT(&sorting_options),
|
||||
|
|
|
|||
|
|
@ -3254,8 +3254,9 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref
|
|||
|
||||
if (filter->start_after)
|
||||
ret = start_ref_iterator_after(iter, filter->start_after);
|
||||
else if (prefix)
|
||||
ret = ref_iterator_seek(iter, prefix, 1);
|
||||
else
|
||||
ret = ref_iterator_seek(iter, prefix,
|
||||
REF_ITERATOR_SEEK_SET_PREFIX);
|
||||
|
||||
if (!ret)
|
||||
ret = do_for_each_ref_iterator(iter, fn, cb_data);
|
||||
|
|
|
|||
|
|
@ -498,13 +498,14 @@ static int cache_ref_iterator_seek(struct ref_iterator *ref_iterator,
|
|||
* indexing to each level as needed.
|
||||
*/
|
||||
do {
|
||||
int len, idx;
|
||||
int idx;
|
||||
size_t len;
|
||||
int cmp = 0;
|
||||
|
||||
sort_ref_dir(dir);
|
||||
|
||||
slash = strchr(slash, '/');
|
||||
len = slash ? slash - refname : (int)strlen(refname);
|
||||
len = slash ? (size_t)(slash - refname) : strlen(refname);
|
||||
|
||||
for (idx = 0; idx < dir->nr; idx++) {
|
||||
cmp = strncmp(refname, dir->entries[idx]->name, len);
|
||||
|
|
|
|||
|
|
@ -712,6 +712,25 @@ test_expect_success 'start after, overflow specific reference path' '
|
|||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'start after, with exclude pattern' '
|
||||
cat >expect <<-\EOF &&
|
||||
refs/tags/annotated-tag
|
||||
refs/tags/doubly-annotated-tag
|
||||
refs/tags/doubly-signed-tag
|
||||
refs/tags/foo1.10
|
||||
refs/tags/foo1.3
|
||||
refs/tags/foo1.6
|
||||
refs/tags/four
|
||||
refs/tags/one
|
||||
refs/tags/signed-tag
|
||||
refs/tags/three
|
||||
refs/tags/two
|
||||
EOF
|
||||
git for-each-ref --format="%(refname)" --start-after=refs/odd/spot \
|
||||
--exclude=refs/tags/foo >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'start after, last reference' '
|
||||
cat >expect <<-\EOF &&
|
||||
EOF
|
||||
|
|
|
|||
Loading…
Reference in New Issue