{"thread":{"id":"63835","subject":"[PATCH 0/5] ref-filter: small cleanups and fixes","startedAt":"2025-07-24T08:14:57Z","lastAt":"2025-07-29T08:04:37Z","messageCount":22,"participants":["Karthik Nayak","Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"522639","messageId":"20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com","threadId":"63835","inReplyTo":null,"subject":"[PATCH 0/5] ref-filter: small cleanups and fixes","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-24T08:14:41Z","receivedAt":"2025-07-24T08:14:57Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"This series contains a few of the small fixes and comments which I've\ngathered from reviews of my earlier series [1] to add the\n'--start-after' flag to 'git-for-each-ref(1)'.\n\nIndividually each patch doesn't hold too much weight on its own, but\ntogether these small improvements add up. That said, if these patches\nare too small for the noise generated, we could simply drop it or\ncombine some commits together.\n\nThis is based on top of 3f2a94875d (The twelfth batch, 2025-07-21) with\n'kn/for-each-ref-skip' merged in.\n\n[1]: https://lore.kernel.org/r/20250701-306-git-for-each-ref-pagination-v1-0-4f0ae7c0688f@gmail.com\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/git-for-each-ref.adoc |  9 +++++----\n builtin/for-each-ref.c              |  2 +-\n ref-filter.c                        |  5 +++--\n refs/ref-cache.c                    |  5 +++--\n t/t6302-for-each-ref-filter.sh      | 19 +++++++++++++++++++\n 5 files changed, 31 insertions(+), 9 deletions(-)\n\nKarthik Nayak (5):\n      ref-cache: use 'size_t' instead of int for length\n      for-each-ref: fix documentation argument ordering\n      for-each-ref: reword the documentation for '--start-after'\n      t6302: add test combining '--start-after' with '--exclude'\n      ref-filter: use REF_ITERATOR_SEEK_SET_PREFIX instead of '1'\n\n\n\nbase-commit: 15fcbd8f16a2c119a5319b0657e52fe0f387df46\nchange-id: 20250721-kn-small-cleanups-a01fe5d2756d\n\nThanks\n- Karthik\n\n"},{"id":"522640","messageId":"20250724-kn-small-cleanups-v1-1-0c70f591de3e@gmail.com","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com","subject":"[PATCH 1/5] ref-cache: use 'size_t' instead of int for length","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-24T08:14:42Z","receivedAt":"2025-07-24T08:14:58Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The commit 090eb5336c (refs: selectively set prefix in the seek\nfunctions, 2025-07-15) modified the ref-cache iterator to support\nseeking to a specified marker without setting the prefix.\n\nThe commit adds and uses an integer 'len' to capture the length of the\nseek marker to compare with the entries of a given directory. Since the\ntype of the variable is 'int', this is met with a typecast of converting\na `strlen` to 'int' so it can be assigned to the 'len' variable.\n\nThis is whole operation is a bit wrong:\n1. Since the 'len' variable is eventually used in a 'strncmp', it should\nhave been of type 'size_t'.\n2. This also truncates the value provided from 'strlen' to an int, which\ncould cause a large refname to produce a negative number.\n\nLet's do the correct thing here and simply use 'size_t' for `len`.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n refs/ref-cache.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/refs/ref-cache.c b/refs/ref-cache.c\nindex 1d95b56d40..8df7ae43e5 100644\n--- a/refs/ref-cache.c\n+++ b/refs/ref-cache.c\n@@ -498,13 +498,14 @@ static int cache_ref_iterator_seek(struct ref_iterator *ref_iterator,\n \t\t * indexing to each level as needed.\n \t\t */\n \t\tdo {\n-\t\t\tint len, idx;\n+\t\t\tint idx;\n+\t\t\tsize_t len;\n \t\t\tint cmp = 0;\n \n \t\t\tsort_ref_dir(dir);\n \n \t\t\tslash = strchr(slash, '/');\n-\t\t\tlen = slash ? slash - refname : (int)strlen(refname);\n+\t\t\tlen = slash ? (size_t)(slash - refname) : strlen(refname);\n \n \t\t\tfor (idx = 0; idx < dir->nr; idx++) {\n \t\t\t\tcmp = strncmp(refname, dir->entries[idx]->name, len);\n\n-- \n2.49.0\n\n"},{"id":"522641","messageId":"20250724-kn-small-cleanups-v1-2-0c70f591de3e@gmail.com","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com","subject":"[PATCH 2/5] for-each-ref: fix documentation argument ordering","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-24T08:14:43Z","receivedAt":"2025-07-24T08:14:58Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Improve the 'git-for-each-ref(1)' documentation with two corrections:\n\n1. Add parentheses around `--exclude=<pattern>` to indicate this option\n   can be repeated as a complete unit.\n\n2. Move `--stdin | <pattern> ...` to the end, after all flags, since\n   `<pattern>` is a positional argument that should appear last in the\n   argument list.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/git-for-each-ref.adoc | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc\nindex ae61ba642a..a170de4209 100644\n--- a/Documentation/git-for-each-ref.adoc\n+++ b/Documentation/git-for-each-ref.adoc\n@@ -10,11 +10,11 @@ SYNOPSIS\n [verse]\n 'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n \t\t   [(--sort=<key>)...] [--format=<format>]\n-\t\t   [--include-root-refs] [ --stdin | <pattern>... ]\n-\t\t   [--points-at=<object>]\n+\t\t   [--include-root-refs] [--points-at=<object>]\n \t\t   [--merged[=<object>]] [--no-merged[=<object>]]\n \t\t   [--contains[=<object>]] [--no-contains[=<object>]]\n-\t\t   [--exclude=<pattern> ...] [--start-after=<marker>]\n+\t\t   [(--exclude=<pattern>)...] [--start-after=<marker>]\n+           [ --stdin | <pattern>... ]\n \n DESCRIPTION\n -----------\n\n-- \n2.49.0\n\n"},{"id":"522642","messageId":"20250724-kn-small-cleanups-v1-3-0c70f591de3e@gmail.com","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com","subject":"[PATCH 3/5] for-each-ref: reword the documentation for '--start-after'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-24T08:14:44Z","receivedAt":"2025-07-24T08:14:59Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The documentation for '--start-after' states that the flag cannot be\nused with general pattern matching. This is a bit vague, since there is\nno clear understanding about what 'general' means here. Rewrite the\nsentence to be more specific.\n\nWhile here, fix a typo in the 'OPT_STRING'.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/git-for-each-ref.adoc | 3 ++-\n builtin/for-each-ref.c              | 2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc\nindex a170de4209..48af302a6f 100644\n--- a/Documentation/git-for-each-ref.adoc\n+++ b/Documentation/git-for-each-ref.adoc\n@@ -114,7 +114,8 @@ TAB %(refname)`.\n     deleted, modified or added between invocations. Output will only yield those\n     references which follow the marker lexicographically. Output begins from the\n     first reference that would come after the marker alphabetically. Cannot be\n-    used with general pattern matching or custom sort options.\n+    used with `--sort=<key>` or `--stdin` options, or the _<pattern>_ argument(s)\n+    to limit the refs.\n \n FIELD NAMES\n -----------\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 3f21598046..79a79212c9 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -45,7 +45,7 @@ int cmd_for_each_ref(int argc,\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_INTEGER( 0 , \"count\", &format.array_opts.max_count, N_(\"show only <n> matched refs\")),\n \t\tOPT_STRING(  0 , \"format\", &format.format, N_(\"format\"), N_(\"format to use for the output\")),\n-\t\tOPT_STRING(  0 , \"start-after\", &filter.start_after, N_(\"start-start\"), N_(\"start iteration after the provided marker\")),\n+\t\tOPT_STRING(  0 , \"start-after\", &filter.start_after, N_(\"start-after\"), N_(\"start iteration after the provided marker\")),\n \t\tOPT__COLOR(&format.use_color, N_(\"respect format colors\")),\n \t\tOPT_REF_FILTER_EXCLUDE(&filter),\n \t\tOPT_REF_SORT(&sorting_options),\n\n-- \n2.49.0\n\n"},{"id":"522643","messageId":"20250724-kn-small-cleanups-v1-4-0c70f591de3e@gmail.com","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com","subject":"[PATCH 4/5] t6302: add test combining '--start-after' with '--exclude'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-24T08:14:45Z","receivedAt":"2025-07-24T08:15:00Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The '--start-after' doesn't explicitly mention being compatible with the\n'--exclude' flag, generally only incompatibility is explicitly called\nout. However, it would be nice to test the compatibility between the\ntwo to avoid future regressions. Let's do that.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n t/t6302-for-each-ref-filter.sh | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n\ndiff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh\nindex e097db6b02..9b80ea1e3b 100755\n--- a/t/t6302-for-each-ref-filter.sh\n+++ b/t/t6302-for-each-ref-filter.sh\n@@ -712,6 +712,25 @@ test_expect_success 'start after, overflow specific reference path' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'start after, with exclude pattern' '\n+\tcat >expect <<-\\EOF &&\n+\trefs/tags/annotated-tag\n+\trefs/tags/doubly-annotated-tag\n+\trefs/tags/doubly-signed-tag\n+\trefs/tags/foo1.10\n+\trefs/tags/foo1.3\n+\trefs/tags/foo1.6\n+\trefs/tags/four\n+\trefs/tags/one\n+\trefs/tags/signed-tag\n+\trefs/tags/three\n+\trefs/tags/two\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --start-after=refs/odd/spot \\\n+\t\t--exclude=refs/tags/foo >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'start after, last reference' '\n \tcat >expect <<-\\EOF &&\n \tEOF\n\n-- \n2.49.0\n\n"},{"id":"522644","messageId":"20250724-kn-small-cleanups-v1-5-0c70f591de3e@gmail.com","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com","subject":"[PATCH 5/5] ref-filter: use REF_ITERATOR_SEEK_SET_PREFIX instead of '1'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-24T08:14:46Z","receivedAt":"2025-07-24T08:15:00Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In the commit 51511d68f4 (for-each-ref: introduce a '--start-after'\noption, 2025-07-15), for introducing the '--start-after' flag, the\n`ref_iterator_seek()` was modified to also accept a flag. This was to\nallow the function to also set the prefix when\n'REF_ITERATOR_SEEK_SET_PREFIX' was set.\n\nIn `do_filter_refs()` instead of passing the flag, we pass in '1' which\nis the value of the flag. While this works, this is definitely hard to\nread and introduces inconsistency. Change it to use the flag.\n\nWhile here, remove the unnecessary 'if (prefix)' clause in the 'else'\nstatement, since the block already checks for 'prefix'.\n\nReported-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n ref-filter.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex d5a146de87..4edf0df4cc 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -3254,8 +3254,9 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref\n \n \t\tif (filter->start_after)\n \t\t\tret = start_ref_iterator_after(iter, filter->start_after);\n-\t\telse if (prefix)\n-\t\t\tret = ref_iterator_seek(iter, prefix, 1);\n+\t\telse\n+\t\t\tret = ref_iterator_seek(iter, prefix,\n+\t\t\t\t\t\tREF_ITERATOR_SEEK_SET_PREFIX);\n \n \t\tif (!ret)\n \t\t\tret = do_for_each_ref_iterator(iter, fn, cb_data);\n\n-- \n2.49.0\n\n"},{"id":"522692","messageId":"xmqq7bzxik3f.fsf@gitster.g","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-1-0c70f591de3e@gmail.com","subject":"Re: [PATCH 1/5] ref-cache: use 'size_t' instead of int for length","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-07-24T17:17:56Z","receivedAt":"2025-07-24T17:17:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> The commit 090eb5336c (refs: selectively set prefix in the seek\n> functions, 2025-07-15) modified the ref-cache iterator to support\n> seeking to a specified marker without setting the prefix.\n>\n> The commit adds and uses an integer 'len' to capture the length of the\n> seek marker to compare with the entries of a given directory. Since the\n> type of the variable is 'int', this is met with a typecast of converting\n> a `strlen` to 'int' so it can be assigned to the 'len' variable.\n>\n> This is whole operation is a bit wrong:\n> 1. Since the 'len' variable is eventually used in a 'strncmp', it should\n> have been of type 'size_t'.\n> 2. This also truncates the value provided from 'strlen' to an int, which\n> could cause a large refname to produce a negative number.\n>\n> Let's do the correct thing here and simply use 'size_t' for `len`.\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n>  refs/ref-cache.c | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/refs/ref-cache.c b/refs/ref-cache.c\n> index 1d95b56d40..8df7ae43e5 100644\n> --- a/refs/ref-cache.c\n> +++ b/refs/ref-cache.c\n> @@ -498,13 +498,14 @@ static int cache_ref_iterator_seek(struct ref_iterator *ref_iterator,\n>  \t\t * indexing to each level as needed.\n>  \t\t */\n>  \t\tdo {\n> -\t\t\tint len, idx;\n> +\t\t\tint idx;\n> +\t\t\tsize_t len;\n>  \t\t\tint cmp = 0;\n>  \n>  \t\t\tsort_ref_dir(dir);\n>  \n>  \t\t\tslash = strchr(slash, '/');\n> -\t\t\tlen = slash ? slash - refname : (int)strlen(refname);\n> +\t\t\tlen = slash ? (size_t)(slash - refname) : strlen(refname);\n\nThe \"strlen()\" side is good, but was there recently a discussion on\nhow to safely convert (slash - refname) that is ptrdiff_t to size_t?\n\nMy archive search found a rather old ptrdiff_to_size() proposal\nhttps://lore.kernel.org/git/20241227213729.GA796141@coredump.intra.peff.net/\nbut I thought there were another discussion thread about casting to size_t\nrecently.\n\nI _think_ a vanilla cast is safe here, as slash sits always right to\nrefname (if not NULL, that is), and the difference should fit within\nsize_t (because the difference is smaller than the size of the\nmemory block pointed at by slash).\n\nSo in short, this looks good.  Will queue.\n"},{"id":"522694","messageId":"xmqqy0sdh529.fsf@gitster.g","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-2-0c70f591de3e@gmail.com","subject":"Re: [PATCH 2/5] for-each-ref: fix documentation argument ordering","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-07-24T17:27:58Z","receivedAt":"2025-07-24T17:28:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> Improve the 'git-for-each-ref(1)' documentation with two corrections:\n>\n> 1. Add parentheses around `--exclude=<pattern>` to indicate this option\n>    can be repeated as a complete unit.\n>\n> 2. Move `--stdin | <pattern> ...` to the end, after all flags, since\n>    `<pattern>` is a positional argument that should appear last in the\n>    argument list.\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n>  Documentation/git-for-each-ref.adoc | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n>\n> diff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc\n> index ae61ba642a..a170de4209 100644\n> --- a/Documentation/git-for-each-ref.adoc\n> +++ b/Documentation/git-for-each-ref.adoc\n> @@ -10,11 +10,11 @@ SYNOPSIS\n>  [verse]\n>  'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n>  \t\t   [(--sort=<key>)...] [--format=<format>]\n> -\t\t   [--include-root-refs] [ --stdin | <pattern>... ]\n> -\t\t   [--points-at=<object>]\n> +\t\t   [--include-root-refs] [--points-at=<object>]\n>  \t\t   [--merged[=<object>]] [--no-merged[=<object>]]\n>  \t\t   [--contains[=<object>]] [--no-contains[=<object>]]\n> -\t\t   [--exclude=<pattern> ...] [--start-after=<marker>]\n> +\t\t   [(--exclude=<pattern>)...] [--start-after=<marker>]\n> +           [ --stdin | <pattern>... ]\n\nShouldn't the last line align with the others?\n"},{"id":"522695","messageId":"xmqqtt31h4fu.fsf@gitster.g","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com","subject":"Re: [PATCH 0/5] ref-filter: small cleanups and fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-07-24T17:41:25Z","receivedAt":"2025-07-24T17:41:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> This series contains a few of the small fixes and comments which I've\n> gathered from reviews of my earlier series [1] to add the\n> '--start-after' flag to 'git-for-each-ref(1)'.\n>\n> Individually each patch doesn't hold too much weight on its own, but\n> together these small improvements add up. That said, if these patches\n> are too small for the noise generated, we could simply drop it or\n> combine some commits together.\n>\n> This is based on top of 3f2a94875d (The twelfth batch, 2025-07-21) with\n> 'kn/for-each-ref-skip' merged in.\n>\n> [1]: https://lore.kernel.org/r/20250701-306-git-for-each-ref-pagination-v1-0-4f0ae7c0688f@gmail.com\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n>  Documentation/git-for-each-ref.adoc |  9 +++++----\n>  builtin/for-each-ref.c              |  2 +-\n>  ref-filter.c                        |  5 +++--\n>  refs/ref-cache.c                    |  5 +++--\n>  t/t6302-for-each-ref-filter.sh      | 19 +++++++++++++++++++\n>  5 files changed, 31 insertions(+), 9 deletions(-)\n\nWill queue.  All of them made sense.\n\nThanks.\n"},{"id":"522707","messageId":"CAOLa=ZRvyBK9vVz4+OhLUgAyktdVTb44VC=e8KQNB6BszJ0ixA@mail.gmail.com","threadId":"63835","inReplyTo":"xmqqy0sdh529.fsf@gitster.g","subject":"Re: [PATCH 2/5] for-each-ref: fix documentation argument ordering","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-24T22:14:06Z","receivedAt":"2025-07-24T22:14:07Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n>> Improve the 'git-for-each-ref(1)' documentation with two corrections:\n>>\n>> 1. Add parentheses around `--exclude=<pattern>` to indicate this option\n>>    can be repeated as a complete unit.\n>>\n>> 2. Move `--stdin | <pattern> ...` to the end, after all flags, since\n>>    `<pattern>` is a positional argument that should appear last in the\n>>    argument list.\n>>\n>> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n>> ---\n>>  Documentation/git-for-each-ref.adoc | 6 +++---\n>>  1 file changed, 3 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc\n>> index ae61ba642a..a170de4209 100644\n>> --- a/Documentation/git-for-each-ref.adoc\n>> +++ b/Documentation/git-for-each-ref.adoc\n>> @@ -10,11 +10,11 @@ SYNOPSIS\n>>  [verse]\n>>  'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n>>  \t\t   [(--sort=<key>)...] [--format=<format>]\n>> -\t\t   [--include-root-refs] [ --stdin | <pattern>... ]\n>> -\t\t   [--points-at=<object>]\n>> +\t\t   [--include-root-refs] [--points-at=<object>]\n>>  \t\t   [--merged[=<object>]] [--no-merged[=<object>]]\n>>  \t\t   [--contains[=<object>]] [--no-contains[=<object>]]\n>> -\t\t   [--exclude=<pattern> ...] [--start-after=<marker>]\n>> +\t\t   [(--exclude=<pattern>)...] [--start-after=<marker>]\n>> +           [ --stdin | <pattern>... ]\n>\n> Shouldn't the last line align with the others?\n\nIndeed, I blotched it up somehow. Will add it locally and wait a ~day\nbefore sending in a new version.\n"},{"id":"522709","messageId":"xmqqo6t9xlr8.fsf@gitster.g","threadId":"63835","inReplyTo":"CAOLa=ZRvyBK9vVz4+OhLUgAyktdVTb44VC=e8KQNB6BszJ0ixA@mail.gmail.com","subject":"Re: [PATCH 2/5] for-each-ref: fix documentation argument ordering","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-07-24T22:32:59Z","receivedAt":"2025-07-24T22:33:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> Indeed, I blotched it up somehow. Will add it locally and wait a ~day\n> before sending in a new version.\n\nHopefully no need, as I've tweaked a bit locally while queuing.\n"},{"id":"522736","messageId":"aINitJW7Mbxswy4b@pks.im","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-2-0c70f591de3e@gmail.com","subject":"Re: [PATCH 2/5] for-each-ref: fix documentation argument ordering","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-25T10:55:48Z","receivedAt":"2025-07-25T10:55:55Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Jul 24, 2025 at 10:14:43AM +0200, Karthik Nayak wrote:\n> diff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc\n> index ae61ba642a..a170de4209 100644\n> --- a/Documentation/git-for-each-ref.adoc\n> +++ b/Documentation/git-for-each-ref.adoc\n> @@ -10,11 +10,11 @@ SYNOPSIS\n>  [verse]\n>  'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n>  \t\t   [(--sort=<key>)...] [--format=<format>]\n> -\t\t   [--include-root-refs] [ --stdin | <pattern>... ]\n> -\t\t   [--points-at=<object>]\n> +\t\t   [--include-root-refs] [--points-at=<object>]\n>  \t\t   [--merged[=<object>]] [--no-merged[=<object>]]\n>  \t\t   [--contains[=<object>]] [--no-contains[=<object>]]\n> -\t\t   [--exclude=<pattern> ...] [--start-after=<marker>]\n> +\t\t   [(--exclude=<pattern>)...] [--start-after=<marker>]\n> +           [ --stdin | <pattern>... ]\n\nWhile at it we could also convert this to use `[synopsis]`.\n\nPatrick\n"},{"id":"522737","messageId":"aINiuo4GWlW_1Fd-@pks.im","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-3-0c70f591de3e@gmail.com","subject":"Re: [PATCH 3/5] for-each-ref: reword the documentation for '--start-after'","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-25T10:55:54Z","receivedAt":"2025-07-25T10:56:00Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Jul 24, 2025 at 10:14:44AM +0200, Karthik Nayak wrote:\n> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\n> index 3f21598046..79a79212c9 100644\n> --- a/builtin/for-each-ref.c\n> +++ b/builtin/for-each-ref.c\n> @@ -45,7 +45,7 @@ int cmd_for_each_ref(int argc,\n>  \t\tOPT_GROUP(\"\"),\n>  \t\tOPT_INTEGER( 0 , \"count\", &format.array_opts.max_count, N_(\"show only <n> matched refs\")),\n>  \t\tOPT_STRING(  0 , \"format\", &format.format, N_(\"format\"), N_(\"format to use for the output\")),\n> -\t\tOPT_STRING(  0 , \"start-after\", &filter.start_after, N_(\"start-start\"), N_(\"start iteration after the provided marker\")),\n> +\t\tOPT_STRING(  0 , \"start-after\", &filter.start_after, N_(\"start-after\"), N_(\"start iteration after the provided marker\")),\n\nFunny how typos like this frequently go through reviews without anybody\nnoticing :)\n\nPatrick\n"},{"id":"522886","messageId":"CAOLa=ZRB6VJU4Km8jotcEsGMbQeb1Vq+waZriHS9c2RVxiqJhA@mail.gmail.com","threadId":"63835","inReplyTo":"aINitJW7Mbxswy4b@pks.im","subject":"Re: [PATCH 2/5] for-each-ref: fix documentation argument ordering","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-28T20:18:10Z","receivedAt":"2025-07-28T20:18:13Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Thu, Jul 24, 2025 at 10:14:43AM +0200, Karthik Nayak wrote:\n>> diff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc\n>> index ae61ba642a..a170de4209 100644\n>> --- a/Documentation/git-for-each-ref.adoc\n>> +++ b/Documentation/git-for-each-ref.adoc\n>> @@ -10,11 +10,11 @@ SYNOPSIS\n>>  [verse]\n>>  'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n>>  \t\t   [(--sort=<key>)...] [--format=<format>]\n>> -\t\t   [--include-root-refs] [ --stdin | <pattern>... ]\n>> -\t\t   [--points-at=<object>]\n>> +\t\t   [--include-root-refs] [--points-at=<object>]\n>>  \t\t   [--merged[=<object>]] [--no-merged[=<object>]]\n>>  \t\t   [--contains[=<object>]] [--no-contains[=<object>]]\n>> -\t\t   [--exclude=<pattern> ...] [--start-after=<marker>]\n>> +\t\t   [(--exclude=<pattern>)...] [--start-after=<marker>]\n>> +           [ --stdin | <pattern>... ]\n>\n> While at it we could also convert this to use `[synopsis]`.\n>\n> Patrick\n\nThat's a good point, Let me do that.\n"},{"id":"522887","messageId":"CAOLa=ZRTL-V6nmRv4HM8LWu3q52V4Exf50KpF8AHt+hoV4n9Mg@mail.gmail.com","threadId":"63835","inReplyTo":"xmqqo6t9xlr8.fsf@gitster.g","subject":"Re: [PATCH 2/5] for-each-ref: fix documentation argument ordering","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-28T20:19:41Z","receivedAt":"2025-07-28T20:19:42Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n>> Indeed, I blotched it up somehow. Will add it locally and wait a ~day\n>> before sending in a new version.\n>\n> Hopefully no need, as I've tweaked a bit locally while queuing.\n\nThanks, but since Patrick also pointed out about the 'synopsis' block,\nI'll send in a new version with the fix.\n"},{"id":"522888","messageId":"20250728-kn-small-cleanups-v2-0-d3021c8bf471@gmail.com","threadId":"63835","inReplyTo":"20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com","subject":"[PATCH v2 0/5] ref-filter: small cleanups and fixes","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-28T20:20:45Z","receivedAt":"2025-07-28T20:20:53Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"This series contains a few of the small fixes and comments which I've\ngathered from reviews of my earlier series [1] to add the\n'--start-after' flag to 'git-for-each-ref(1)'.\n\nIndividually each patch doesn't hold too much weight on its own, but\ntogether these small improvements add up. That said, if these patches\nare too small for the noise generated, we could simply drop it or\ncombine some commits together.\n\nThis is based on top of 3f2a94875d (The twelfth batch, 2025-07-21) with\n'kn/for-each-ref-skip' merged in.\n\n[1]: https://lore.kernel.org/r/20250701-306-git-for-each-ref-pagination-v1-0-4f0ae7c0688f@gmail.com\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\nChanges in v2:\n- In Patch 2/5, fix a whitespace issue and convert 'git-for-each-ref(1)'\n  documentation to use the new synopsis block.\n- Link to v1: https://lore.kernel.org/r/20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com\n\n---\n Documentation/git-for-each-ref.adoc | 13 +++++++------\n builtin/for-each-ref.c              |  2 +-\n ref-filter.c                        |  5 +++--\n refs/ref-cache.c                    |  5 +++--\n t/t6302-for-each-ref-filter.sh      | 19 +++++++++++++++++++\n 5 files changed, 33 insertions(+), 11 deletions(-)\n\nKarthik Nayak (5):\n      ref-cache: use 'size_t' instead of int for length\n      for-each-ref: fix documentation argument ordering\n      for-each-ref: reword the documentation for '--start-after'\n      t6302: add test combining '--start-after' with '--exclude'\n      ref-filter: use REF_ITERATOR_SEEK_SET_PREFIX instead of '1'\n\nRange-diff versus v1:\n\n1:  449473efe6 = 1:  cb34545b3a ref-cache: use 'size_t' instead of int for length\n2:  b5aec572bc < -:  ---------- for-each-ref: fix documentation argument ordering\n-:  ---------- > 2:  3fab0eda31 for-each-ref: fix documentation argument ordering\n3:  005a35a4b3 = 3:  49e5aa69f2 for-each-ref: reword the documentation for '--start-after'\n4:  162f5de259 = 4:  93babd3e71 t6302: add test combining '--start-after' with '--exclude'\n5:  3eb8591385 = 5:  ce90149919 ref-filter: use REF_ITERATOR_SEEK_SET_PREFIX instead of '1'\n\n\nbase-commit: 15fcbd8f16a2c119a5319b0657e52fe0f387df46\nchange-id: 20250721-kn-small-cleanups-a01fe5d2756d\n\nThanks\n- Karthik\n\n"},{"id":"522890","messageId":"20250728-kn-small-cleanups-v2-1-d3021c8bf471@gmail.com","threadId":"63835","inReplyTo":"20250728-kn-small-cleanups-v2-0-d3021c8bf471@gmail.com","subject":"[PATCH v2 1/5] ref-cache: use 'size_t' instead of int for length","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-28T20:20:46Z","receivedAt":"2025-07-28T20:20:54Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The commit 090eb5336c (refs: selectively set prefix in the seek\nfunctions, 2025-07-15) modified the ref-cache iterator to support\nseeking to a specified marker without setting the prefix.\n\nThe commit adds and uses an integer 'len' to capture the length of the\nseek marker to compare with the entries of a given directory. Since the\ntype of the variable is 'int', this is met with a typecast of converting\na `strlen` to 'int' so it can be assigned to the 'len' variable.\n\nThis is whole operation is a bit wrong:\n1. Since the 'len' variable is eventually used in a 'strncmp', it should\nhave been of type 'size_t'.\n2. This also truncates the value provided from 'strlen' to an int, which\ncould cause a large refname to produce a negative number.\n\nLet's do the correct thing here and simply use 'size_t' for `len`.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n refs/ref-cache.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/refs/ref-cache.c b/refs/ref-cache.c\nindex 1d95b56d40..8df7ae43e5 100644\n--- a/refs/ref-cache.c\n+++ b/refs/ref-cache.c\n@@ -498,13 +498,14 @@ static int cache_ref_iterator_seek(struct ref_iterator *ref_iterator,\n \t\t * indexing to each level as needed.\n \t\t */\n \t\tdo {\n-\t\t\tint len, idx;\n+\t\t\tint idx;\n+\t\t\tsize_t len;\n \t\t\tint cmp = 0;\n \n \t\t\tsort_ref_dir(dir);\n \n \t\t\tslash = strchr(slash, '/');\n-\t\t\tlen = slash ? slash - refname : (int)strlen(refname);\n+\t\t\tlen = slash ? (size_t)(slash - refname) : strlen(refname);\n \n \t\t\tfor (idx = 0; idx < dir->nr; idx++) {\n \t\t\t\tcmp = strncmp(refname, dir->entries[idx]->name, len);\n\n-- \n2.50.0\n\n"},{"id":"522889","messageId":"20250728-kn-small-cleanups-v2-2-d3021c8bf471@gmail.com","threadId":"63835","inReplyTo":"20250728-kn-small-cleanups-v2-0-d3021c8bf471@gmail.com","subject":"[PATCH v2 2/5] for-each-ref: fix documentation argument ordering","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-28T20:20:47Z","receivedAt":"2025-07-28T20:20:55Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Improve the 'git-for-each-ref(1)' documentation with two corrections:\n\n1. Add parentheses around `--exclude=<pattern>` to indicate this option\n   can be repeated as a complete unit.\n\n2. Move `--stdin | <pattern> ...` to the end, after all flags, since\n   `<pattern>` is a positional argument that should appear last in the\n   argument list.\n\nWhile here, change to using the synopsis block which will automatically\nformat placeholders in italics and keywords in monospace.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/git-for-each-ref.adoc | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc\nindex ae61ba642a..ec3b10e14a 100644\n--- a/Documentation/git-for-each-ref.adoc\n+++ b/Documentation/git-for-each-ref.adoc\n@@ -7,14 +7,14 @@ git-for-each-ref - Output information on each ref\n \n SYNOPSIS\n --------\n-[verse]\n-'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n+[synopsis]\n+git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl]\n \t\t   [(--sort=<key>)...] [--format=<format>]\n-\t\t   [--include-root-refs] [ --stdin | <pattern>... ]\n-\t\t   [--points-at=<object>]\n+\t\t   [--include-root-refs] [--points-at=<object>]\n \t\t   [--merged[=<object>]] [--no-merged[=<object>]]\n \t\t   [--contains[=<object>]] [--no-contains[=<object>]]\n-\t\t   [--exclude=<pattern> ...] [--start-after=<marker>]\n+\t\t   [(--exclude=<pattern>)...] [--start-after=<marker>]\n+\t\t   [ --stdin | <pattern>... ]\n \n DESCRIPTION\n -----------\n\n-- \n2.50.0\n\n"},{"id":"522891","messageId":"20250728-kn-small-cleanups-v2-3-d3021c8bf471@gmail.com","threadId":"63835","inReplyTo":"20250728-kn-small-cleanups-v2-0-d3021c8bf471@gmail.com","subject":"[PATCH v2 3/5] for-each-ref: reword the documentation for '--start-after'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-28T20:20:48Z","receivedAt":"2025-07-28T20:20:56Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The documentation for '--start-after' states that the flag cannot be\nused with general pattern matching. This is a bit vague, since there is\nno clear understanding about what 'general' means here. Rewrite the\nsentence to be more specific.\n\nWhile here, fix a typo in the 'OPT_STRING'.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/git-for-each-ref.adoc | 3 ++-\n builtin/for-each-ref.c              | 2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc\nindex ec3b10e14a..060940904d 100644\n--- a/Documentation/git-for-each-ref.adoc\n+++ b/Documentation/git-for-each-ref.adoc\n@@ -114,7 +114,8 @@ TAB %(refname)`.\n     deleted, modified or added between invocations. Output will only yield those\n     references which follow the marker lexicographically. Output begins from the\n     first reference that would come after the marker alphabetically. Cannot be\n-    used with general pattern matching or custom sort options.\n+    used with `--sort=<key>` or `--stdin` options, or the _<pattern>_ argument(s)\n+    to limit the refs.\n \n FIELD NAMES\n -----------\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 3f21598046..79a79212c9 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -45,7 +45,7 @@ int cmd_for_each_ref(int argc,\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_INTEGER( 0 , \"count\", &format.array_opts.max_count, N_(\"show only <n> matched refs\")),\n \t\tOPT_STRING(  0 , \"format\", &format.format, N_(\"format\"), N_(\"format to use for the output\")),\n-\t\tOPT_STRING(  0 , \"start-after\", &filter.start_after, N_(\"start-start\"), N_(\"start iteration after the provided marker\")),\n+\t\tOPT_STRING(  0 , \"start-after\", &filter.start_after, N_(\"start-after\"), N_(\"start iteration after the provided marker\")),\n \t\tOPT__COLOR(&format.use_color, N_(\"respect format colors\")),\n \t\tOPT_REF_FILTER_EXCLUDE(&filter),\n \t\tOPT_REF_SORT(&sorting_options),\n\n-- \n2.50.0\n\n"},{"id":"522892","messageId":"20250728-kn-small-cleanups-v2-4-d3021c8bf471@gmail.com","threadId":"63835","inReplyTo":"20250728-kn-small-cleanups-v2-0-d3021c8bf471@gmail.com","subject":"[PATCH v2 4/5] t6302: add test combining '--start-after' with '--exclude'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-28T20:20:49Z","receivedAt":"2025-07-28T20:20:56Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The '--start-after' doesn't explicitly mention being compatible with the\n'--exclude' flag, generally only incompatibility is explicitly called\nout. However, it would be nice to test the compatibility between the\ntwo to avoid future regressions. Let's do that.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n t/t6302-for-each-ref-filter.sh | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n\ndiff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh\nindex e097db6b02..9b80ea1e3b 100755\n--- a/t/t6302-for-each-ref-filter.sh\n+++ b/t/t6302-for-each-ref-filter.sh\n@@ -712,6 +712,25 @@ test_expect_success 'start after, overflow specific reference path' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'start after, with exclude pattern' '\n+\tcat >expect <<-\\EOF &&\n+\trefs/tags/annotated-tag\n+\trefs/tags/doubly-annotated-tag\n+\trefs/tags/doubly-signed-tag\n+\trefs/tags/foo1.10\n+\trefs/tags/foo1.3\n+\trefs/tags/foo1.6\n+\trefs/tags/four\n+\trefs/tags/one\n+\trefs/tags/signed-tag\n+\trefs/tags/three\n+\trefs/tags/two\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --start-after=refs/odd/spot \\\n+\t\t--exclude=refs/tags/foo >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'start after, last reference' '\n \tcat >expect <<-\\EOF &&\n \tEOF\n\n-- \n2.50.0\n\n"},{"id":"522893","messageId":"20250728-kn-small-cleanups-v2-5-d3021c8bf471@gmail.com","threadId":"63835","inReplyTo":"20250728-kn-small-cleanups-v2-0-d3021c8bf471@gmail.com","subject":"[PATCH v2 5/5] ref-filter: use REF_ITERATOR_SEEK_SET_PREFIX instead of '1'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-07-28T20:20:50Z","receivedAt":"2025-07-28T20:20:57Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In the commit 51511d68f4 (for-each-ref: introduce a '--start-after'\noption, 2025-07-15), for introducing the '--start-after' flag, the\n`ref_iterator_seek()` was modified to also accept a flag. This was to\nallow the function to also set the prefix when\n'REF_ITERATOR_SEEK_SET_PREFIX' was set.\n\nIn `do_filter_refs()` instead of passing the flag, we pass in '1' which\nis the value of the flag. While this works, this is definitely hard to\nread and introduces inconsistency. Change it to use the flag.\n\nWhile here, remove the unnecessary 'if (prefix)' clause in the 'else'\nstatement, since the block already checks for 'prefix'.\n\nReported-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n ref-filter.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex d5a146de87..4edf0df4cc 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -3254,8 +3254,9 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref\n \n \t\tif (filter->start_after)\n \t\t\tret = start_ref_iterator_after(iter, filter->start_after);\n-\t\telse if (prefix)\n-\t\t\tret = ref_iterator_seek(iter, prefix, 1);\n+\t\telse\n+\t\t\tret = ref_iterator_seek(iter, prefix,\n+\t\t\t\t\t\tREF_ITERATOR_SEEK_SET_PREFIX);\n \n \t\tif (!ret)\n \t\t\tret = do_for_each_ref_iterator(iter, fn, cb_data);\n\n-- \n2.50.0\n\n"},{"id":"522931","messageId":"aIiAj8COJOAXv-xe@pks.im","threadId":"63835","inReplyTo":"20250728-kn-small-cleanups-v2-0-d3021c8bf471@gmail.com","subject":"Re: [PATCH v2 0/5] ref-filter: small cleanups and fixes","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-29T08:04:31Z","receivedAt":"2025-07-29T08:04:37Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Jul 28, 2025 at 10:20:45PM +0200, Karthik Nayak wrote:\n> This series contains a few of the small fixes and comments which I've\n> gathered from reviews of my earlier series [1] to add the\n> '--start-after' flag to 'git-for-each-ref(1)'.\n> \n> Individually each patch doesn't hold too much weight on its own, but\n> together these small improvements add up. That said, if these patches\n> are too small for the noise generated, we could simply drop it or\n> combine some commits together.\n> \n> This is based on top of 3f2a94875d (The twelfth batch, 2025-07-21) with\n> 'kn/for-each-ref-skip' merged in.\n> \n> [1]: https://lore.kernel.org/r/20250701-306-git-for-each-ref-pagination-v1-0-4f0ae7c0688f@gmail.com\n> \n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n> Changes in v2:\n> - In Patch 2/5, fix a whitespace issue and convert 'git-for-each-ref(1)'\n>   documentation to use the new synopsis block.\n> - Link to v1: https://lore.kernel.org/r/20250724-kn-small-cleanups-v1-0-0c70f591de3e@gmail.com\n\nThanks, this version looks good to me.\n\nPatrick\n"}]}