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

[PATCH v2 1/2] completion: stop showing 'save' for stash by default

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Apr 19, 2018, 23:25 UTC
Message-ID
<20180419232514.16572-2-t.gummerer@gmail.com>
In-Reply-To
<20180419232514.16572-1-t.gummerer@gmail.com>

The 'save' subcommand in git stash has been deprecated in fd2ebf14db ("stash: mark "git stash save" deprecated in the man page", 2017-10-22).

Stop showing it when the users enters 'git stash <tab>' or 'git stash s<tab>'. Keep showing it however when the user enters 'git stash sa<tab>' or any more characters of the 'save' subcommand. This is designed to not encourage users to use 'git stash save', but still leaving the completion option once it's clear that's what the user means.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
---
 contrib/completion/git-completion.bash | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a757073945..9a95b3b7b1 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2774,13 +2774,18 @@ _git_show_branch ()
 _git_stash ()
 {
 	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
-	local subcommands='push save list show apply clear drop pop create branch'
-	local subcommand="$(__git_find_on_cmdline "$subcommands")"
+	local subcommands='push list show apply clear drop pop create branch'
+	local subcommand="$(__git_find_on_cmdline "$subcommands save")"
 	if [ -z "$subcommand" ]; then
 		case "$cur" in
 		--*)
 			__gitcomp "$save_opts"
 			;;
+		sa*)
+			if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
+				__gitcomp "save"
+			fi
+			;;
 		*)
 			if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
 				__gitcomp "$subcommands"
-- 
2.17.0.252.gfe0a9eaf31
Previous: Thomas GummererNext: Duy Nguyen
Message 8 of 12 in “completion: improvements for git stash”
  1. 0/3 completion: improvements for git stashThomas Gummerer, Apr 17, 2018
  2. 1/3 completion: rename save_opts to default_opts for stashThomas Gummerer, Apr 17, 2018
  3. 2/3 completion: stop completing 'save' as stash subcommandThomas Gummerer, Apr 17, 2018
  4. 3/3 completion: make stash -p and alias for stash push -pThomas Gummerer, Apr 17, 2018
  5. Junio C HamanoApr 18, 2018
  6. Thomas GummererApr 18, 2018
  7. 0/2 completion: improvements for git stashThomas Gummerer, Apr 19, 2018
  8. 1/2 completion: stop showing 'save' for stash by defaultThomas Gummerer, Apr 19, 2018
  9. Duy NguyenApr 20, 2018
  10. Thomas GummererApr 22, 2018
  11. 2/2 completion: make stash -p and alias for stash push -pThomas Gummerer, Apr 19, 2018
  12. Junio C HamanoApr 20, 2018

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.