{"thread":{"id":"66114","subject":"[PATCH] completion: add 'git history' subcommands","startedAt":"2026-08-04T19:56:41Z","lastAt":"2026-08-19T20:18:13Z","messageCount":18,"participants":["Vincent Mailhol","Patrick Steinhardt","D. Ben Knoble","Junio C Hamano","Kristoffer Haugsbakk"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"549608","messageId":"20260804-history_autocompletion-v1-1-6f7459ffb677@kernel.org","threadId":"66114","inReplyTo":null,"subject":"[PATCH] completion: add 'git history' subcommands","fromName":"Vincent Mailhol","fromEmail":"mailhol@kernel.org","sentAt":"2026-08-04T19:56:32Z","receivedAt":"2026-08-04T19:56:41Z","isPatch":true,"body":"Use the parse-options completion helpers for the \"git history\"\nsubcommands and their options. Complete positional arguments as\nrevisions, and add coverage for each kind of completion.\n\nSigned-off-by: Vincent Mailhol <mailhol@kernel.org>\n---\n contrib/completion/git-completion.bash | 24 ++++++++++++++++++++++++\n t/t9902-completion.sh                  | 17 +++++++++++++++++\n 2 files changed, 41 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e875787710..f10813c8d7 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2137,6 +2137,30 @@ _git_help ()\n \tfi\n }\n \n+_git_history ()\n+{\n+\tlocal subcommands subcommand\n+\n+\t__git_resolve_builtins \"history\"\n+\n+\tsubcommands=\"$___git_resolved_builtins\"\n+\tsubcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n+\n+\tif [ -z \"$subcommand\" ]; then\n+\t\t__gitcomp \"$subcommands\"\n+\t\treturn\n+\tfi\n+\n+\tcase \"$cur\" in\n+\t--*)\n+\t\t__gitcomp_builtin \"history_$subcommand\"\n+\t\t;;\n+\t*)\n+\t\t__git_complete_refs\n+\t\t;;\n+\tesac\n+}\n+\n _git_init ()\n {\n \tcase \"$cur\" in\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 9ae3c48ebd..08ecf682ed 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -3107,6 +3107,23 @@ test_expect_success 'git clone --config= - value' '\n \tEOF\n '\n \n+test_expect_success 'git history subcommands' '\n+\ttest_completion \"git history \" <<-\\EOF\n+\tdrop Z\n+\tfixup Z\n+\treword Z\n+\tsplit Z\n+\tEOF\n+'\n+\n+test_expect_success 'git history subcommand options' '\n+\ttest_completion \"git history fixup --upd\" \"--update-refs=\"\n+'\n+\n+test_expect_success 'git history revisions' '\n+\ttest_completion \"git history split ma\" \"main \"\n+'\n+\n test_expect_success 'git reflog show' '\n \ttest_when_finished \"git checkout - && git branch -d shown\" &&\n \tgit checkout -b shown &&\n\n---\nbase-commit: 5b2471720c93ee30e5764a19f3d3b3ae9ec9712a\nchange-id: 20260804-history_autocompletion-84620c2f8500\n\n"},{"id":"549642","messageId":"anLV__4THdvugj8f@pks.im","threadId":"66114","inReplyTo":"20260804-history_autocompletion-v1-1-6f7459ffb677@kernel.org","subject":"Re: [PATCH] completion: add 'git history' subcommands","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-08-05T06:19:43Z","receivedAt":"2026-08-05T06:19:50Z","isPatch":true,"body":"On Tue, Aug 04, 2026 at 09:56:32PM +0200, Vincent Mailhol wrote:\n> Use the parse-options completion helpers for the \"git history\"\n> subcommands and their options. Complete positional arguments as\n> revisions, and add coverage for each kind of completion.\n\nAh, great! I wanted to write shell completion for git-history(1) for a\nwhile but never really found the time to actually do it.\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index e875787710..f10813c8d7 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2137,6 +2137,30 @@ _git_help ()\n>  \tfi\n>  }\n>  \n> +_git_history ()\n> +{\n> +\tlocal subcommands subcommand\n> +\n> +\t__git_resolve_builtins \"history\"\n> +\n> +\tsubcommands=\"$___git_resolved_builtins\"\n> +\tsubcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n> +\n> +\tif [ -z \"$subcommand\" ]; then\n> +\t\t__gitcomp \"$subcommands\"\n> +\t\treturn\n> +\tfi\n\nOkay. We first try to figure out whether there is any subcommand passed\nby the user already. If not, we complete available subcommands.\n\n> +\tcase \"$cur\" in\n> +\t--*)\n> +\t\t__gitcomp_builtin \"history_$subcommand\"\n> +\t\t;;\n> +\t*)\n> +\t\t__git_complete_refs\n> +\t\t;;\n> +\tesac\n> +}\n\nOtherwise we try to either complete available options if we see a\nleading \"--\", or alternatively we complete references. This works well\nfor \"drop\", \"fixup\" and \"reword\".\n\nThe one command where this falls flat a bit is `git history split`.\nWhile the first non-option argument is indeed a reference, subsequent\narguments are pathspecs. So ideally, we'd notice that we already have a\nreference there and, if so, complete file paths.\n\nBut that being said, I think this is a good-enough first iteration and a\nstrict improvement over the status quo -- we don't have to be perfect\nright from the start. So if you want to also make that case work then\ngreat, but I won't insist on it.\n\n> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\n> index 9ae3c48ebd..08ecf682ed 100755\n> --- a/t/t9902-completion.sh\n> +++ b/t/t9902-completion.sh\n> @@ -3107,6 +3107,23 @@ test_expect_success 'git clone --config= - value' '\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'git history subcommands' '\n> +\ttest_completion \"git history \" <<-\\EOF\n> +\tdrop Z\n> +\tfixup Z\n> +\treword Z\n> +\tsplit Z\n> +\tEOF\n> +'\n\nThis will cause conflicts with \"seen\", as there's a new upcoming\n\"squash\" command that's currently cooking there. That's fine though,\nnothing you can do about that.\n\nThanks!\n\nPatrick\n"},{"id":"549683","messageId":"CALnO6CCbivaD8ZwD0+mVs4LXqkTzyc1T1Nt7eS-dYbTdQQw5KQ@mail.gmail.com","threadId":"66114","inReplyTo":"anLV__4THdvugj8f@pks.im","subject":"Re: [PATCH] completion: add 'git history' subcommands","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-08-05T11:56:23Z","receivedAt":"2026-08-05T11:56:35Z","isPatch":true,"body":"Hi all,\n\nI agree with Patrick's review below, this looks good to me! One note…\n\nOn Wed, Aug 5, 2026 at 2:25 AM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Tue, Aug 04, 2026 at 09:56:32PM +0200, Vincent Mailhol wrote:\n> > Use the parse-options completion helpers for the \"git history\"\n> > subcommands and their options. Complete positional arguments as\n> > revisions, and add coverage for each kind of completion.\n>\n> Ah, great! I wanted to write shell completion for git-history(1) for a\n> while but never really found the time to actually do it.\n>\n> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> > index e875787710..f10813c8d7 100644\n> > --- a/contrib/completion/git-completion.bash\n> > +++ b/contrib/completion/git-completion.bash\n> > @@ -2137,6 +2137,30 @@ _git_help ()\n> >       fi\n> >  }\n> >\n> > +_git_history ()\n> > +{\n> > +     local subcommands subcommand\n> > +\n> > +     __git_resolve_builtins \"history\"\n> > +\n> > +     subcommands=\"$___git_resolved_builtins\"\n> > +     subcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n> > +\n> > +     if [ -z \"$subcommand\" ]; then\n> > +             __gitcomp \"$subcommands\"\n> > +             return\n> > +     fi\n>\n> Okay. We first try to figure out whether there is any subcommand passed\n> by the user already. If not, we complete available subcommands.\n>\n> > +     case \"$cur\" in\n> > +     --*)\n> > +             __gitcomp_builtin \"history_$subcommand\"\n> > +             ;;\n> > +     *)\n> > +             __git_complete_refs\n> > +             ;;\n> > +     esac\n> > +}\n>\n> Otherwise we try to either complete available options if we see a\n> leading \"--\", or alternatively we complete references. This works well\n> for \"drop\", \"fixup\" and \"reword\".\n>\n> The one command where this falls flat a bit is `git history split`.\n> While the first non-option argument is indeed a reference, subsequent\n> arguments are pathspecs. So ideally, we'd notice that we already have a\n> reference there and, if so, complete file paths.\n\n…here: I think it's probably going to look a bit like what _git_reflog\nand _git_config do, checking the subcommand and using somewhat more\nspecific completion in that case.\n\nBTW, I'm also reminded of <xmqqpl6g9fyu.fsf@gitster.g>, where Junio\nsuggested we devise a way to improve _git_stash. Looking at it again\nwith some context, I bet we can reuse the __git_resolve_builtins\npattern there, too. Not for this patch, of course, just thinking\naloud!\n\n> But that being said, I think this is a good-enough first iteration and a\n> strict improvement over the status quo -- we don't have to be perfect\n> right from the start. So if you want to also make that case work then\n> great, but I won't insist on it.\n>\n> > diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\n> > index 9ae3c48ebd..08ecf682ed 100755\n> > --- a/t/t9902-completion.sh\n> > +++ b/t/t9902-completion.sh\n> > @@ -3107,6 +3107,23 @@ test_expect_success 'git clone --config= - value' '\n> >       EOF\n> >  '\n> >\n> > +test_expect_success 'git history subcommands' '\n> > +     test_completion \"git history \" <<-\\EOF\n> > +     drop Z\n> > +     fixup Z\n> > +     reword Z\n> > +     split Z\n> > +     EOF\n> > +'\n>\n> This will cause conflicts with \"seen\", as there's a new upcoming\n> \"squash\" command that's currently cooking there. That's fine though,\n> nothing you can do about that.\n>\n> Thanks!\n>\n> Patrick\n\nThanks!\n\n-- \nD. Ben Knoble\n"},{"id":"549743","messageId":"xmqq7bm4sfvh.fsf@gitster.g","threadId":"66114","inReplyTo":"anLV__4THdvugj8f@pks.im","subject":"Re: [PATCH] completion: add 'git history' subcommands","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-08-05T16:15:30Z","receivedAt":"2026-08-05T16:15:37Z","isPatch":true,"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Tue, Aug 04, 2026 at 09:56:32PM +0200, Vincent Mailhol wrote:\n>> Use the parse-options completion helpers for the \"git history\"\n>> subcommands and their options. Complete positional arguments as\n>> revisions, and add coverage for each kind of completion.\n>\n> Ah, great! I wanted to write shell completion for git-history(1) for a\n> while but never really found the time to actually do it.\n>\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index e875787710..f10813c8d7 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -2137,6 +2137,30 @@ _git_help ()\n>>  \tfi\n>>  }\n>>  \n>> +_git_history ()\n>> +{\n>> +\tlocal subcommands subcommand\n>> +\n>> +\t__git_resolve_builtins \"history\"\n>> +\n>> +\tsubcommands=\"$___git_resolved_builtins\"\n>> +\tsubcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n>> +\n>> +\tif [ -z \"$subcommand\" ]; then\n>> +\t\t__gitcomp \"$subcommands\"\n>> +\t\treturn\n>> +\tfi\n>\n> Okay. We first try to figure out whether there is any subcommand passed\n> by the user already. If not, we complete available subcommands.\n\nThis may be a tangent, but anyway.  I was looking at this patch (not\nthat I think I am capable of giving a completion patch a serious\nreview), comparing with other completions, and the similarity of the\nboilerplate part above was so striking.  I suspect that these were\norganically grown, but at some point when the tree is quiescent, can\nwe coalesce the completion routines for subcommands that share the\nsame pattern for better maintainability?\n\nThanks.\n"},{"id":"549778","messageId":"6a8e934e-5ccc-40cc-877b-d1f1752888de@kernel.org","threadId":"66114","inReplyTo":"xmqq7bm4sfvh.fsf@gitster.g","subject":"Re: [PATCH] completion: add 'git history' subcommands","fromName":"Vincent Mailhol","fromEmail":"mailhol@kernel.org","sentAt":"2026-08-05T21:20:58Z","receivedAt":"2026-08-05T21:21:03Z","isPatch":true,"body":"On 05/08/2026 at 18:15, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n>> On Tue, Aug 04, 2026 at 09:56:32PM +0200, Vincent Mailhol wrote:\n>>> Use the parse-options completion helpers for the \"git history\"\n>>> subcommands and their options. Complete positional arguments as\n>>> revisions, and add coverage for each kind of completion.\n>>\n>> Ah, great! I wanted to write shell completion for git-history(1) for a\n>> while but never really found the time to actually do it.\n>>\n>>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>>> index e875787710..f10813c8d7 100644\n>>> --- a/contrib/completion/git-completion.bash\n>>> +++ b/contrib/completion/git-completion.bash\n>>> @@ -2137,6 +2137,30 @@ _git_help ()\n>>>  \tfi\n>>>  }\n>>>  \n>>> +_git_history ()\n>>> +{\n>>> +\tlocal subcommands subcommand\n>>> +\n>>> +\t__git_resolve_builtins \"history\"\n>>> +\n>>> +\tsubcommands=\"$___git_resolved_builtins\"\n>>> +\tsubcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n>>> +\n>>> +\tif [ -z \"$subcommand\" ]; then\n>>> +\t\t__gitcomp \"$subcommands\"\n>>> +\t\treturn\n>>> +\tfi\n>>\n>> Okay. We first try to figure out whether there is any subcommand passed\n>> by the user already. If not, we complete available subcommands.\n> \n> This may be a tangent, but anyway.  I was looking at this patch (not\n> that I think I am capable of giving a completion patch a serious\n> review), comparing with other completions, and the similarity of the\n> boilerplate part above was so striking.  I suspect that these were\n> organically grown, but at some point when the tree is quiescent, can\n> we coalesce the completion routines for subcommands that share the\n> same pattern for better maintainability?\n\nI am not sure if this would increase the maintainability.\n\nFor example, I started looking at Patrick's suggestion ※ to cover the\n\n  git history split\n\nspecial case. If we add this, we would need to dispatch this in\n_git_history() by adding something like:\n\n\tif [ \"$subcommand\" = \"split\" ]; then\n\t\t__git_complete_history_split\n\t\treturn\n\tfi\n\nbut if we coalesce the completion routine for the subcommands, where\nshould this dispatcher go?\n\nI see this boilerplate as a skeleton waiting for extensions. Of course,\nmaybe I am missing some points and maybe we can coalesce the code while\nstill allowing for extensions. But currently, I am not able to depict\nhow this should look like.\n\n\n※ The fact that I started to look at the 'git history split' completion\ndoesn't mean that I am committing myself to implement it. I will do a\nbest effort try in my available time. If I get a decent result, I will\nshare, if not, I would ask you to bear with the current patch!\n\n\nYours sincerely,\nVincent Mailhol\n\n"},{"id":"549786","messageId":"anQZKJLIiL1MP_Nx@pks.im","threadId":"66114","inReplyTo":"6a8e934e-5ccc-40cc-877b-d1f1752888de@kernel.org","subject":"Re: [PATCH] completion: add 'git history' subcommands","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-08-06T05:18:32Z","receivedAt":"2026-08-06T05:18:38Z","isPatch":true,"body":"On Wed, Aug 05, 2026 at 11:20:58PM +0200, Vincent Mailhol wrote:\n> On 05/08/2026 at 18:15, Junio C Hamano wrote:\n> ※ The fact that I started to look at the 'git history split' completion\n> doesn't mean that I am committing myself to implement it. I will do a\n> best effort try in my available time. If I get a decent result, I will\n> share, if not, I would ask you to bear with the current patch!\n\nWorks for me. Would be great if you could give us an update though over\nthe next days to say whether you will or will not submit a v2 with `git\nhistory split`.\n\nThanks!\n\nPatrick\n"},{"id":"550556","messageId":"20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org","threadId":"66114","inReplyTo":"20260804-history_autocompletion-v1-1-6f7459ffb677@kernel.org","subject":"[PATCH v3 0/4] completion: add support for 'git history'","fromName":"Vincent Mailhol","fromEmail":"mailhol@kernel.org","sentAt":"2026-08-13T19:05:01Z","receivedAt":"2026-08-13T19:05:25Z","isPatch":true,"body":"This series adds Bash completion for the subcommands of \"git history\"\nand their options.\n\nPatch #1 adds the basic subcommand and options completion. Patch #2 and\n\noptions. Finally, Patch #4 adds completion for pathspecs accepted by\n\"split\".\n\nFor each of the completions, add a set of relevant test cases.\n\nSigned-off-by: Vincent Mailhol <mailhol@kernel.org>\n---\nChanges in v3:\n\n  - Ignore the split \"<option> <value>\" syntax for options that take\n    arguments. This simplifies revision detection and avoids hard-coding\n    option names.\n  - Test that options are not completed before a subcommand.\n\nLink to v2: https://lore.kernel.org/r/20260806-history_autocompletion-v2-0-7e60f52a1c20@kernel.org\n\nChanges in v2:\n\n  - Complete exactly one required revision and leave subsequent\n    arguments to subcommand-specific completion.\n  - Do not complete options after \"--\".\n  - Complete values for \"--empty\" and \"--update-refs\".\n  - Complete pathspecs for \"git history split\".\n  - Expand the test coverage for options, revisions, and pathspecs.\n\nLink to v1: https://lore.kernel.org/r/20260804-history_autocompletion-v1-1-6f7459ffb677@kernel.org\n\n---\nVincent Mailhol (4):\n      completion: add 'git history' subcommands\n      completion: complete 'git history --empty' values\n      completion: complete 'git history --update-refs' values\n      completion: complete 'git history split' pathspecs\n\n contrib/completion/git-completion.bash | 65 ++++++++++++++++++++++++++++++++++\n t/t9902-completion.sh                  | 50 ++++++++++++++++++++++++++\n 2 files changed, 115 insertions(+)\n\nRange-diff versus v2:\n\n1:  529ecbe28c ! 1:  5764875d09 completion: add 'git history' subcommands\n    @@ Commit message\n     \n         Signed-off-by: Vincent Mailhol <mailhol@kernel.org>\n         ---\n    +    Changes in v3:\n    +\n    +      - Ignore the split \"<option> <value>\" syntax for options that take\n    +        arguments. This simplifies revision detection and avoids hard-coding\n    +        option names.\n    +      - Test that options are not completed before a subcommand.\n    +\n         Changes in v2:\n     \n           - Test options before and after revisions.\n           - Do not complete options after \"--\".\n    -      - Stop revision completion after the first required\n    +      - Stop revision completion after the first required revision.\n     \n      ## contrib/completion/git-completion.bash ##\n     @@ contrib/completion/git-completion.bash: _git_help ()\n    @@ contrib/completion/git-completion.bash: _git_help ()\n     +\n     +\tfor ((i = __git_cmd_idx + 2; i < cword; i++)); do\n     +\t\tcase \"${words[i]}\" in\n    -+\t\t--empty|--update-refs)\n    -+\t\t\t((i++))\n    -+\t\t\t;;\n     +\t\t-*)\n     +\t\t\t;;\n     +\t\t*)\n    @@ t/t9902-completion.sh: test_expect_success 'git clone --config= - value' '\n      '\n      \n     +test_expect_success 'git history subcommands' '\n    -+\ttest_completion \"git history \" <<-\\EOF\n    ++\ttest_completion \"git history \" <<-\\EOF &&\n     +\tdrop Z\n     +\tfixup Z\n     +\treword Z\n     +\tsplit Z\n     +\tEOF\n    ++\ttest_completion \"git history --\" \"\"\n     +'\n     +\n     +test_expect_success 'git history subcommand options' '\n    @@ t/t9902-completion.sh: test_expect_success 'git clone --config= - value' '\n     +\n     +test_expect_success 'git history revisions' '\n     +\ttest_completion \"git history split ma\" \"main \" &&\n    -+\ttest_completion \"git history split --update-refs head ma\" \"main \" &&\n    -+\ttest_completion \"git history fixup --empty drop ma\" \"main \" &&\n    ++\ttest_completion \"git history split --update-refs=head ma\" \"main \" &&\n    ++\ttest_completion \"git history fixup --empty=drop ma\" \"main \" &&\n     +\ttest_completion \"git history reword main m\" \"\"\n     +'\n     +\n2:  691965330f < -:  ---------- completion: complete 'git history --empty' values\n3:  02303a7762 < -:  ---------- completion: complete 'git history --update-refs' values\n-:  ---------- > 2:  224fb8dc32 completion: complete 'git history --empty' values\n-:  ---------- > 3:  60a54d5a8b completion: complete 'git history --update-refs' values\n4:  39823df359 ! 4:  c895589110 completion: complete 'git history split' pathspecs\n    @@ Commit message\n     \n         Signed-off-by: Vincent Mailhol <mailhol@kernel.org>\n         ---\n    +    Changes in v3:\n    +\n    +      - No changes.\n    +\n         Changes in v2:\n     \n           - New patch.\n\n---\nbase-commit: 4f2b99511996c64e58c74e2b8bd3d7ec33452a47\nchange-id: 20260804-history_autocompletion-84620c2f8500\n\n"},{"id":"550557","messageId":"20260813-history_autocompletion-v3-1-69eed1cea93a@kernel.org","threadId":"66114","inReplyTo":"20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org","subject":"[PATCH v3 1/4] completion: add 'git history' subcommands","fromName":"Vincent Mailhol","fromEmail":"mailhol@kernel.org","sentAt":"2026-08-13T19:05:02Z","receivedAt":"2026-08-13T19:05:27Z","isPatch":true,"body":"Use the parse-options completion helpers for the\n\n  git history\n\nsubcommands and their options. All current history subcommands take a\nrevision as their first positional argument, so complete that argument\nas a revision.\n\nOnce the revision is present, leave any further positional arguments to\nsubcommand-specific completion. This allows a subcommand to complete\nanother kind of argument, such as the pathspec accepted by\n\n  git history split\n\nor another revision if a future subcommand accepts one.\n\nSigned-off-by: Vincent Mailhol <mailhol@kernel.org>\n---\nChanges in v3:\n\n  - Ignore the split \"<option> <value>\" syntax for options that take\n    arguments. This simplifies revision detection and avoids hard-coding\n    option names.\n  - Test that options are not completed before a subcommand.\n\nChanges in v2:\n\n  - Test options before and after revisions.\n  - Do not complete options after \"--\".\n  - Stop revision completion after the first required revision.\n---\n contrib/completion/git-completion.bash | 45 ++++++++++++++++++++++++++++++++++\n t/t9902-completion.sh                  | 30 +++++++++++++++++++++++\n 2 files changed, 75 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e875787710..1727768487 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2137,6 +2137,51 @@ _git_help ()\n \tfi\n }\n \n+__git_history_has_revision ()\n+{\n+\tlocal i\n+\n+\tfor ((i = __git_cmd_idx + 2; i < cword; i++)); do\n+\t\tcase \"${words[i]}\" in\n+\t\t-*)\n+\t\t\t;;\n+\t\t*)\n+\t\t\treturn 0\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+\treturn 1\n+}\n+\n+_git_history ()\n+{\n+\tlocal subcommands subcommand\n+\n+\t__git_resolve_builtins \"history\"\n+\n+\tsubcommands=\"$___git_resolved_builtins\"\n+\tsubcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n+\n+\tif [ -z \"$subcommand\" ]; then\n+\t\t__gitcomp \"$subcommands\"\n+\t\treturn\n+\tfi\n+\n+\tif ! __git_has_doubledash; then\n+\t\tcase \"$cur\" in\n+\t\t--*)\n+\t\t\t__gitcomp_builtin \"history_$subcommand\"\n+\t\t\treturn\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\n+\tif ! __git_history_has_revision; then\n+\t\t__git_complete_refs\n+\t\treturn\n+\tfi\n+}\n+\n _git_init ()\n {\n \tcase \"$cur\" in\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 9ae3c48ebd..d0d8f2ba4a 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -3107,6 +3107,36 @@ test_expect_success 'git clone --config= - value' '\n \tEOF\n '\n \n+test_expect_success 'git history subcommands' '\n+\ttest_completion \"git history \" <<-\\EOF &&\n+\tdrop Z\n+\tfixup Z\n+\treword Z\n+\tsplit Z\n+\tEOF\n+\ttest_completion \"git history --\" \"\"\n+'\n+\n+test_expect_success 'git history subcommand options' '\n+\ttest_completion \"git history split main --\" <<-\\EOF &&\n+\t--update-refs=Z\n+\t--dry-run Z\n+\t--no-dry-run Z\n+\tEOF\n+\ttest_completion \"git history fixup --upd\" \"--update-refs=\" &&\n+\ttest_completion \"git history fixup --ree\" \"--reedit-message \" &&\n+\ttest_completion \"git history split --upd\" \"--update-refs=\" &&\n+\ttest_completion \"git history split main --dry\" \"--dry-run \" &&\n+\ttest_completion \"git history reword main -- --d\" \"\"\n+'\n+\n+test_expect_success 'git history revisions' '\n+\ttest_completion \"git history split ma\" \"main \" &&\n+\ttest_completion \"git history split --update-refs=head ma\" \"main \" &&\n+\ttest_completion \"git history fixup --empty=drop ma\" \"main \" &&\n+\ttest_completion \"git history reword main m\" \"\"\n+'\n+\n test_expect_success 'git reflog show' '\n \ttest_when_finished \"git checkout - && git branch -d shown\" &&\n \tgit checkout -b shown &&\n\n-- \n2.54.0\n\n"},{"id":"550558","messageId":"20260813-history_autocompletion-v3-2-69eed1cea93a@kernel.org","threadId":"66114","inReplyTo":"20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org","subject":"[PATCH v3 2/4] completion: complete 'git history --empty' values","fromName":"Vincent Mailhol","fromEmail":"mailhol@kernel.org","sentAt":"2026-08-13T19:05:03Z","receivedAt":"2026-08-13T19:05:29Z","isPatch":true,"body":"The \"--empty\" option accepts \"drop\", \"keep\", or \"abort\" for the \"drop\"\nand \"fixup\" subcommands. Complete these values for the documented\n\n  --empty=<value>\n\nform.\n\nWhile parse-options also accepts the split\n\n  --empty <value>\n\nform, it is not documented. Omit it from completion as a trade-off for\ncode simplicity.\n\nSigned-off-by: Vincent Mailhol <mailhol@kernel.org>\n---\nChanges in v3:\n\n  - Complete only the documented stuck form.\n\nChanges in v2:\n\n  - New patch.\n---\n contrib/completion/git-completion.bash | 9 +++++++++\n t/t9902-completion.sh                  | 6 +++++-\n 2 files changed, 14 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1727768487..7f3cabd595 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2169,6 +2169,15 @@ _git_history ()\n \n \tif ! __git_has_doubledash; then\n \t\tcase \"$cur\" in\n+\t\t--empty=*)\n+\t\t\tcase \"$subcommand\" in\n+\t\t\tdrop|fixup)\n+\t\t\t\t__gitcomp \"drop keep abort\" \"\" \\\n+\t\t\t\t\t\"${cur##--empty=}\"\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\treturn\n+\t\t\t;;\n \t\t--*)\n \t\t\t__gitcomp_builtin \"history_$subcommand\"\n \t\t\treturn\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex d0d8f2ba4a..851be383e1 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -3127,7 +3127,11 @@ test_expect_success 'git history subcommand options' '\n \ttest_completion \"git history fixup --ree\" \"--reedit-message \" &&\n \ttest_completion \"git history split --upd\" \"--update-refs=\" &&\n \ttest_completion \"git history split main --dry\" \"--dry-run \" &&\n-\ttest_completion \"git history reword main -- --d\" \"\"\n+\ttest_completion \"git history reword main -- --d\" \"\" &&\n+\ttest_completion \"git history fixup --empty=ke\" \"keep \" &&\n+\ttest_completion \"git history fixup --empty=drop\" \"drop \" &&\n+\ttest_completion \"git history drop --empty=ab\" \"abort \" &&\n+\ttest_completion \"git history reword --empty=ke\" \"\"\n '\n \n test_expect_success 'git history revisions' '\n\n-- \n2.54.0\n\n"},{"id":"550559","messageId":"20260813-history_autocompletion-v3-3-69eed1cea93a@kernel.org","threadId":"66114","inReplyTo":"20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org","subject":"[PATCH v3 3/4] completion: complete 'git history --update-refs' values","fromName":"Vincent Mailhol","fromEmail":"mailhol@kernel.org","sentAt":"2026-08-13T19:05:04Z","receivedAt":"2026-08-13T19:05:31Z","isPatch":true,"body":"The \"--update-refs\" option accepts either \"branches\" or \"head\".\nComplete these values for the documented\n\n  --update-refs=<value>\n\nform.\n\nWhile parse-options also accepts the split\n\n  --update-refs <value>\n\nform, it is not documented. Omit it from completion as a trade-off for\ncode simplicity.\n\nSigned-off-by: Vincent Mailhol <mailhol@kernel.org>\n---\nChanges in v3:\n\n  - Complete only the documented stuck form.\n\nChanges in v2:\n\n  - New patch.\n---\n contrib/completion/git-completion.bash | 5 +++++\n t/t9902-completion.sh                  | 5 ++++-\n 2 files changed, 9 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7f3cabd595..19600940dc 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2178,6 +2178,11 @@ _git_history ()\n \t\t\tesac\n \t\t\treturn\n \t\t\t;;\n+\t\t--update-refs=*)\n+\t\t\t__gitcomp \"branches head\" \"\" \\\n+\t\t\t\t\"${cur##--update-refs=}\"\n+\t\t\treturn\n+\t\t\t;;\n \t\t--*)\n \t\t\t__gitcomp_builtin \"history_$subcommand\"\n \t\t\treturn\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 851be383e1..b225dd3800 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -3131,7 +3131,10 @@ test_expect_success 'git history subcommand options' '\n \ttest_completion \"git history fixup --empty=ke\" \"keep \" &&\n \ttest_completion \"git history fixup --empty=drop\" \"drop \" &&\n \ttest_completion \"git history drop --empty=ab\" \"abort \" &&\n-\ttest_completion \"git history reword --empty=ke\" \"\"\n+\ttest_completion \"git history reword --empty=ke\" \"\" &&\n+\ttest_completion \"git history fixup --update-refs=branch\" \"branches \" &&\n+\ttest_completion \"git history split --update-refs=he\" \"head \" &&\n+\ttest_completion \"git history reword main -- --update-refs=he\" \"\"\n '\n \n test_expect_success 'git history revisions' '\n\n-- \n2.54.0\n\n"},{"id":"550560","messageId":"20260813-history_autocompletion-v3-4-69eed1cea93a@kernel.org","threadId":"66114","inReplyTo":"20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org","subject":"[PATCH v3 4/4] completion: complete 'git history split' pathspecs","fromName":"Vincent Mailhol","fromEmail":"mailhol@kernel.org","sentAt":"2026-08-13T19:05:05Z","receivedAt":"2026-08-13T19:05:34Z","isPatch":true,"body":"Arguments following the required revision of \"git history split\" are\npathspecs. Complete them from tracked paths, including after an explicit\n\"--\".\n\nSigned-off-by: Vincent Mailhol <mailhol@kernel.org>\n---\nChanges in v3:\n\n  - No changes.\n\nChanges in v2:\n\n  - New patch.\n---\n contrib/completion/git-completion.bash |  6 ++++++\n t/t9902-completion.sh                  | 13 +++++++++++++\n 2 files changed, 19 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 19600940dc..6172b6182f 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2194,6 +2194,12 @@ _git_history ()\n \t\t__git_complete_refs\n \t\treturn\n \tfi\n+\n+\tcase \"$subcommand\" in\n+\tsplit)\n+\t\t__git_complete_index_file \"--cached\"\n+\t\t;;\n+\tesac\n }\n \n _git_init ()\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex b225dd3800..194bca8d6c 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -3144,6 +3144,19 @@ test_expect_success 'git history revisions' '\n \ttest_completion \"git history reword main m\" \"\"\n '\n \n+test_expect_success 'git history split pathspecs' '\n+\ttest_completion \"git history split main -- --update-refs=h\" \"\" &&\n+\ttest_completion \"git history split main -- --update-refs h\" \"\" &&\n+\ttest_completion \"git history split --dry-run main file\" <<-\\EOF &&\n+\tfile1Z\n+\tfile2Z\n+\tEOF\n+\ttest_completion \"git history split main -- file\" <<-\\EOF\n+\tfile1Z\n+\tfile2Z\n+\tEOF\n+'\n+\n test_expect_success 'git reflog show' '\n \ttest_when_finished \"git checkout - && git branch -d shown\" &&\n \tgit checkout -b shown &&\n\n-- \n2.54.0\n\n"},{"id":"550576","messageId":"bd3707a8-70ad-4308-bc93-5aad84e028d6@app.fastmail.com","threadId":"66114","inReplyTo":"20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org","subject":"Re: [PATCH v3 0/4] completion: add support for 'git history'","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-08-13T20:30:59Z","receivedAt":"2026-08-13T20:31:26Z","isPatch":true,"body":"On Thu, Aug 13, 2026, at 21:05, Vincent Mailhol wrote:\n> This series adds Bash completion for the subcommands of \"git history\"\n> and their options.\n>\n> Patch #1 adds the basic subcommand and options completion. Patch #2 and\n>\n> options. Finally, Patch #4 adds completion for pathspecs accepted by\n> \"split\".\n\nIt looks like one line was accidentally deleted/blanked. But I think \nit would say the same thing as on v2:\n\n---\nPatch #1 adds the basic subcommand and options completion. Patch #2\nand #3 take care of the value of the --empty and --update-refs options.\nFinally, Patch #4 adds completion for pathspecs accepted by \"split\".\n---\n\nWas the paragraph reflowed with \n\"#3\" at the start and treated like\na comment line?\n\n>\n>[snip]\n\nsent from mobile\n"},{"id":"550589","messageId":"3d0e8944-c17b-4665-88e0-2f955d52e8e9@kernel.org","threadId":"66114","inReplyTo":"bd3707a8-70ad-4308-bc93-5aad84e028d6@app.fastmail.com","subject":"Re: [PATCH v3 0/4] completion: add support for 'git history'","fromName":"Vincent Mailhol","fromEmail":"mailhol@kernel.org","sentAt":"2026-08-14T06:25:17Z","receivedAt":"2026-08-14T06:25:22Z","isPatch":true,"body":"On 13/08/2026 at 22:30, Kristoffer Haugsbakk wrote:\n> On Thu, Aug 13, 2026, at 21:05, Vincent Mailhol wrote:\n>> This series adds Bash completion for the subcommands of \"git history\"\n>> and their options.\n>>\n>> Patch #1 adds the basic subcommand and options completion. Patch #2 and\n>>\n>> options. Finally, Patch #4 adds completion for pathspecs accepted by\n>> \"split\".\n> \n> It looks like one line was accidentally deleted/blanked. But I think \n> it would say the same thing as on v2:\n> \n> ---\n> Patch #1 adds the basic subcommand and options completion. Patch #2\n> and #3 take care of the value of the --empty and --update-refs options.\n> Finally, Patch #4 adds completion for pathspecs accepted by \"split\".\n> ---\n> \n> Was the paragraph reflowed with \n> \"#3\" at the start and treated like\n> a comment line?\n\nExactly.\n\nThis is the cover letter as I intended to send it:\n\n  completion: add support for 'git history'\n  \n  This series adds Bash completion for the subcommands of \"git history\"\n  and their options.\n  \n  Patch #1 adds the basic subcommand and options completion. Patch #2 and\n  #3 take care of, respectively, the value of the --empty and --update-refs\n  options. Finally, Patch #4 adds completion for pathspecs accepted by\n  \"split\".\n  \n  For each of the completions, add a set of relevant test cases.\n\nAs you guessed, b4 removed the line starting with #3. I didn't see this\ncoming. From now on, I will stop using # in the description.\n\nShould I send a v4 with the fixed cover letter, or is it OK as-is?\n\n\nYours sincerely,\nVincent Mailhol\n\n"},{"id":"550599","messageId":"7dd74cba-2149-4d31-9d45-2c355137bf0d@app.fastmail.com","threadId":"66114","inReplyTo":"3d0e8944-c17b-4665-88e0-2f955d52e8e9@kernel.org","subject":"Re: [PATCH v3 0/4] completion: add support for 'git history'","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-08-14T07:50:22Z","receivedAt":"2026-08-14T07:50:49Z","isPatch":true,"body":"On Fri, Aug 14, 2026, at 08:25, Vincent Mailhol wrote:\n>[snip]\n> As you guessed, b4 removed the line starting with #3. I didn't see this\n> coming. From now on, I will stop using # in the description.\n\nYou have a new enough Git (2.54.0) that you can use `core.commentString`\nif you like. And with that you can set it to a string that you would\nnever type yourself.\n\nThat’s more of an assurance than `core.commentChar` which was limited to\none ASCII character.\n\n>\n> Should I send a v4 with the fixed cover letter, or is it OK as-is?\n\nNo, no new version necessary. It wasn’t my intention to make a reroll\nout of a molehill.\n"},{"id":"550796","messageId":"aoWPzTx0OUgg0mzH@pks.im","threadId":"66114","inReplyTo":"20260813-history_autocompletion-v3-1-69eed1cea93a@kernel.org","subject":"Re: [PATCH v3 1/4] completion: add 'git history' subcommands","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-08-19T11:13:17Z","receivedAt":"2026-08-19T11:13:31Z","isPatch":true,"body":"On Thu, Aug 13, 2026 at 09:05:02PM +0200, Vincent Mailhol wrote:\n> Changes in v3:\n> \n>   - Ignore the split \"<option> <value>\" syntax for options that take\n>     arguments. This simplifies revision detection and avoids hard-coding\n>     option names.\n>   - Test that options are not completed before a subcommand.\n\nYeah, this version is a lot more maintainable. It will have false\npositives, but I think we shouldn't let perfect be the enemy of good.\n\nPatrick\n"},{"id":"550797","messageId":"aoWP2OHLMDmNBBBv@pks.im","threadId":"66114","inReplyTo":"20260813-history_autocompletion-v3-2-69eed1cea93a@kernel.org","subject":"Re: [PATCH v3 2/4] completion: complete 'git history --empty' values","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-08-19T11:13:28Z","receivedAt":"2026-08-19T11:13:34Z","isPatch":true,"body":"On Thu, Aug 13, 2026 at 09:05:03PM +0200, Vincent Mailhol wrote:\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 1727768487..7f3cabd595 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2169,6 +2169,15 @@ _git_history ()\n>  \n>  \tif ! __git_has_doubledash; then\n>  \t\tcase \"$cur\" in\n> +\t\t--empty=*)\n> +\t\t\tcase \"$subcommand\" in\n> +\t\t\tdrop|fixup)\n> +\t\t\t\t__gitcomp \"drop keep abort\" \"\" \\\n> +\t\t\t\t\t\"${cur##--empty=}\"\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\treturn\n> +\t\t\t;;\n\nIt would've been fine to just do this for every subcommand, I guess. But\nthis version works for me, too.\n\nPatrick\n"},{"id":"550798","messageId":"aoWP3TYq5rNjUx7S@pks.im","threadId":"66114","inReplyTo":"20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org","subject":"Re: [PATCH v3 0/4] completion: add support for 'git history'","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-08-19T11:13:33Z","receivedAt":"2026-08-19T11:13:40Z","isPatch":true,"body":"On Thu, Aug 13, 2026 at 09:05:01PM +0200, Vincent Mailhol wrote:\n> Changes in v3:\n> \n>   - Ignore the split \"<option> <value>\" syntax for options that take\n>     arguments. This simplifies revision detection and avoids hard-coding\n>     option names.\n>   - Test that options are not completed before a subcommand.\n\nI'm happy with this version and I think it's a good base to build on\ngoing forward. Thanks!\n\nPatrick\n"},{"id":"550840","messageId":"xmqqse49uanx.fsf@gitster.g","threadId":"66114","inReplyTo":"aoWP3TYq5rNjUx7S@pks.im","subject":"Re: [PATCH v3 0/4] completion: add support for 'git history'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-08-19T20:18:10Z","receivedAt":"2026-08-19T20:18:13Z","isPatch":true,"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Thu, Aug 13, 2026 at 09:05:01PM +0200, Vincent Mailhol wrote:\n>> Changes in v3:\n>> \n>>   - Ignore the split \"<option> <value>\" syntax for options that take\n>>     arguments. This simplifies revision detection and avoids hard-coding\n>>     option names.\n>>   - Test that options are not completed before a subcommand.\n>\n> I'm happy with this version and I think it's a good base to build on\n> going forward. Thanks!\n>\n> Patrick\n\nThanks, both.\n\nI'll prepare an evil-merge to rewrite the test to add 'squash' to\nthe candidatesto adjust to the subcommand addition to another topic\nin-flight brings in when merging these patches to 'seen'.\n\nVincent, this is strictly FYI.  You do not need to rebase on top of\nthe other topic, until I and/or the author of the other topic ask\nyou.\n\nThanks.\n"}]}