From: Ben Knoble <ben.knoble@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH 1/5] completion: simplify stash subcommand completion
Date: Mon, 19 Oct 2026 15:58:24 -0400 [thread overview]
Message-ID: <2076548D-473E-4EC7-AE92-3DCBF1D3A4F1@gmail.com> (raw)
In-Reply-To: <atHZzrybhYzMVGbQ@pks.im>
> Le 16 oct. 2026 à 04:01, Patrick Steinhardt <ps@pks.im> a écrit :
>
> On Mon, Oct 12, 2026 at 01:48:27PM -0400, D. Ben Knoble wrote:
>> The stash completion helper contains a hard-coded list of commands, but
>> git-stash provides a mechanism to list such commands
>> (--git-completion-helper). The pattern for using it is wrapped by
>> __git_resolve_builtins, so use it, bring _git_stash closer in line with
>
> s/bring/bringing/?
Will fix!
>> other completion helpers.
>>
>> Note that we maintain the "save" special case, since it was removed from
>> default completion in 0eb5a4f911 (completion: stop showing 'save' for
>> stash by default, 2018-04-20). We don't have to do anything special with
>> the exclude (3rd) argument to __git_resolve_builtins, though, because
>> save is already marked PARSE_OPT_NOCOMPLETE.
>
> I didn't understand the last sentence without going into the code.
>
> I assume what you want to say is that we don't have to explicitly
> exclude it when completing the subcommand because it's already marked as
> NOCOMPLETE. But we don't want to fully ignore it, either, because we
> want to be able to complete that subcommand if the user explicitly wrote
> it?
>
> So basically: we're not completing it if the user writes "git stash
> sa<TAB>", but we then know to complete its options if the user writes
> "git stash save --<TAB>". Which I guess makes sense for a deprecated
> subcommand.
Correct. I got a little too familiar with the completion guts
while working on this. I’ll try reworking it when I get back to v2.
>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
>> index c3a49e2e22..d60e85479c 100644
>> --- a/contrib/completion/git-completion.bash
>> +++ b/contrib/completion/git-completion.bash
>> @@ -3553,8 +3553,12 @@ _git_sparse_checkout ()
>>
>> _git_stash ()
>> {
>> - local subcommands='push list show apply clear drop pop create branch import export'
>> - local subcommand="$(__git_find_on_cmdline "$subcommands save")"
>> + local subcommands subcommand
>> +
>> + __git_resolve_builtins stash
>> +
>> + subcommands="$___git_resolved_builtins"
>> + subcommand="$(__git_find_on_cmdline "$subcommands save")"
>
> More plumbing, but less stuff that we need to keep up-to-date.
And more aligned with other helpers, yep.
> This also
> fixes that the "store" subcommand wasn't completed, which should
> probably be pointed out in the commit message.
I missed that, will add. Thanks!
next prev parent reply other threads:[~2026-10-19 19:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 17:48 [PATCH 0/5] stash completion miscellany D. Ben Knoble
2026-10-12 17:48 ` [PATCH 1/5] completion: simplify stash subcommand completion D. Ben Knoble
2026-10-16 8:01 ` Patrick Steinhardt
2026-10-19 19:58 ` Ben Knoble [this message]
2026-10-12 17:48 ` [PATCH 2/5] completion: extract common stash listing code D. Ben Knoble
2026-10-12 17:48 ` [PATCH 3/5] completion: fix Zsh handling of stash names D. Ben Knoble
2026-10-16 8:01 ` Patrick Steinhardt
2026-10-19 19:56 ` Ben Knoble
2026-10-12 17:48 ` [PATCH 4/5] doc: drop usage mentions of "git stash save" D. Ben Knoble
2026-10-16 8:01 ` Patrick Steinhardt
2026-10-12 17:48 ` [PATCH 5/5] completion: drop "stash save" completion altogether D. Ben Knoble
2026-10-16 8:01 ` Patrick Steinhardt
2026-10-19 20:01 ` Ben Knoble
2026-10-20 6:05 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2076548D-473E-4EC7-AE92-3DCBF1D3A4F1@gmail.com \
--to=ben.knoble@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox