git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/5] completion: simplify stash subcommand completion

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 16, 2026, 08:01 UTC
Message-ID
<atHZzrybhYzMVGbQ@pks.im>
In-Reply-To
<d0e461a14a254cae7d15aa6b62deedb4a0ac6deb.1791827304.git.ben.knoble@gmail.com>
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/?
Show 7 quoted lines
> 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.

Show 16 quoted lines
> 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. This also fixes that the "store" subcommand wasn't completed, which should probably be pointed out in the commit message.

Patrick
Previous: D. Ben KnobleNext: Ben Knoble
Message 3 of 28 in “stash completion miscellany”
  1. 0/5 stash completion miscellanyD. Ben Knoble, Oct 12, 2026
  2. 1/5 completion: simplify stash subcommand completionD. Ben Knoble, Oct 12, 2026
  3. Patrick SteinhardtOct 16, 2026
  4. Ben KnobleOct 19, 2026
  5. 2/5 completion: extract common stash listing codeD. Ben Knoble, Oct 12, 2026
  6. 3/5 completion: fix Zsh handling of stash namesD. Ben Knoble, Oct 12, 2026
  7. Patrick SteinhardtOct 16, 2026
  8. Ben KnobleOct 19, 2026
  9. 4/5 doc: drop usage mentions of "git stash save"D. Ben Knoble, Oct 12, 2026
  10. Patrick SteinhardtOct 16, 2026
  11. 5/5 completion: drop "stash save" completion altogetherD. Ben Knoble, Oct 12, 2026
  12. Patrick SteinhardtOct 16, 2026
  13. Ben KnobleOct 19, 2026
  14. Patrick SteinhardtOct 20, 2026
  15. D. Ben KnobleOct 22, 2026
  16. Patrick SteinhardtOct 23, 2026
  17. 0/5 stash completion miscellanyD. Ben Knoble, Oct 23, 2026
  18. 1/5 completion: simplify stash subcommand completionD. Ben Knoble, Oct 23, 2026
  19. 2/5 Completion: extract common stash listing codeD. Ben Knoble, Oct 23, 2026
  20. Junio C HamanoOct 23, 2026
  21. 3/5 completion: fix Zsh handling of stash namesD. Ben Knoble, Oct 23, 2026
  22. 4/5 doc: drop usage mentions of "git stash save"D. Ben Knoble, Oct 23, 2026
  23. 5/5 completion: drop "stash save" completion altogetherD. Ben Knoble, Oct 23, 2026
  24. Junio C HamanoOct 23, 2026
  25. Ben KnobleOct 23, 2026
  26. Kristoffer HaugsbakkOct 23, 2026
  27. Patrick SteinhardtOct 26, 2026
  28. Junio C HamanoOct 26, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.