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

[PATCH 2/2] bash: complete 'git stash' subcommands only once

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Mar 5, 2008, 19:16 UTC
Message-ID
<59b1b35932d76bc6b8cc50d2a1184fec7d0d903d.1204725800.git.szeder@ira.uka.de>
In-Reply-To
<9956781bfd3f6ec8776c055aa21a4d3d4a504623.1204725800.git.szeder@ira.uka.de>
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index d138bda..5ecdca0 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1087,7 +1087,22 @@ _git_show ()
 
 _git_stash ()
 {
-	__gitcomp 'save list show apply clear'
+	local i c=1 command
+
+	while [ $c -lt $COMP_CWORD ]; do
+		i="${COMP_WORDS[c]}"
+		case "$i" in
+		save|list|show|apply|clear)
+			command="$i"
+			break
+			;;
+		esac
+		c=$((++c))
+	done
+
+	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+		__gitcomp 'save list show apply clear'
+	fi
 }
 
 _git_submodule ()
-- 
1.5.4.3
Previous: SZEDER Gábor
Message 2 of 2 in “bash: add missing 'git stash save' subcommand”
  1. 1/2 bash: add missing 'git stash save' subcommandSZEDER Gábor, Mar 5, 2008
  2. 2/2 bash: complete 'git stash' subcommands only onceSZEDER Gábor, Mar 5, 2008

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.