Merge branch 'dk/stash-completion-updates'

The command-line completion for 'git stash' has been updated to
dynamically discover subcommands and to correct a Zsh-specific
formatting issue where stash references were improperly unquoted.
Additionally, the deprecated 'save' subcommand has been removed from
completions and synopsis documentation.

* dk/stash-completion-updates:
  completion: drop "stash save" completion altogether
  doc: drop usage mentions of "git stash save"
  completion: fix Zsh handling of stash names
  Completion: extract common stash listing code
  completion: simplify stash subcommand completion
This commit is contained in:
Junio C Hamano committed 2026-11-04 11:04:26 -08:00
commit 2ef78ae7ef
4 files changed
+18 -12

No files matched your search

-2
View File
@@ -18,8 +18,6 @@ git stash [push] [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | -
[-u | --include-untracked] [-a | --all] [(-m | --message) <message>] [-u | --include-untracked] [-a | --all] [(-m | --message) <message>]
[--pathspec-from-file=<file> [--pathspec-file-nul]] [--pathspec-from-file=<file> [--pathspec-file-nul]]
[--] [<pathspec>...] [--] [<pathspec>...]
git stash save [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
[-u | --include-untracked] [-a | --all] [<message>]
git stash clear git stash clear
git stash create [<message>] git stash create [<message>]
git stash store [(-m | --message) <message>] [-q | --quiet] <commit> git stash store [(-m | --message) <message>] [-q | --quiet] <commit>
-1
View File
@@ -74,7 +74,6 @@ static const char * const git_stash_usage[] = {
BUILTIN_STASH_APPLY_USAGE, BUILTIN_STASH_APPLY_USAGE,
BUILTIN_STASH_BRANCH_USAGE, BUILTIN_STASH_BRANCH_USAGE,
BUILTIN_STASH_PUSH_USAGE, BUILTIN_STASH_PUSH_USAGE,
BUILTIN_STASH_SAVE_USAGE,
BUILTIN_STASH_CLEAR_USAGE, BUILTIN_STASH_CLEAR_USAGE,
BUILTIN_STASH_CREATE_USAGE, BUILTIN_STASH_CREATE_USAGE,
BUILTIN_STASH_STORE_USAGE, BUILTIN_STASH_STORE_USAGE,
+13 -9
View File
@@ -3553,17 +3553,18 @@ _git_sparse_checkout ()
_git_stash () _git_stash ()
{ {
local subcommands='push list show apply clear drop pop create branch import export' local subcommands subcommand
local subcommand="$(__git_find_on_cmdline "$subcommands save")"
__git_resolve_builtins stash
subcommands="$___git_resolved_builtins"
subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
case "$((cword - __git_cmd_idx)),$cur" in case "$((cword - __git_cmd_idx)),$cur" in
*,--*) *,--*)
__gitcomp_builtin stash_push __gitcomp_builtin stash_push
;; ;;
1,sa*)
__gitcomp "save"
;;
1,*) 1,*)
__gitcomp "$subcommands" __gitcomp "$subcommands"
;; ;;
@@ -3589,20 +3590,23 @@ _git_stash ()
if [ $cword -eq $((__git_cmd_idx+2)) ]; then if [ $cword -eq $((__git_cmd_idx+2)) ]; then
__git_complete_refs __git_complete_refs
else else
__gitcomp_nl "$(__git stash list \ __git_complete_stashes
| sed -n -e 's/:.*//p')"
fi fi
;; ;;
import,*) import,*)
__git_complete_refs __git_complete_refs
;; ;;
show,*|apply,*|drop,*|pop,*|export,*) show,*|apply,*|drop,*|pop,*|export,*)
__gitcomp_nl "$(__git stash list \ __git_complete_stashes
| sed -n -e 's/:.*//p')"
;; ;;
esac esac
} }
__git_complete_stashes ()
{
__gitcomp_nl "$(__git stash list | sed -n -e 's/:.*//p')"
}
_git_submodule () _git_submodule ()
{ {
__git_has_doubledash && return __git_has_doubledash && return
+5
View File
@@ -135,6 +135,11 @@ __gitcomp_file_direct ()
__gitcomp_file "$1" "" __gitcomp_file "$1" ""
} }
__git_complete_stashes ()
{
compadd -S ' ' -- ${(f)"$(__git stash list | sed -n -e 's/:.*//p')"} && _ret=0
}
_git_zsh () _git_zsh ()
{ {
__gitcomp "v1.1" __gitcomp "v1.1"