[PATCH 1/5] completion: simplify stash subcommand completion
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Oct 12, 2026, 17:48 UTC
- Message-ID
- <d0e461a14a254cae7d15aa6b62deedb4a0ac6deb.1791827304.git.ben.knoble@gmail.com>
- In-Reply-To
- <cover.1791827304.git.ben.knoble@gmail.com>
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 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.
Signed-off-by: D. Ben Knoble <ben.knoble@gmail.com> --- contrib/completion/git-completion.bash | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
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")" if [ -z "$subcommand" ]; then case "$((cword - __git_cmd_idx)),$cur" in
-- 2.56.0.184.g5a00b4a6e9.dirty