threads / patch / 12522

patch, 2 partsbash: add missing 'git stash save' subcommand

Subject: [PATCH 1/2] bash: add missing 'git stash save' subcommand

## tl;dr

2 messages between Mar 5, 2008 and Mar 5, 2008. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

SZEDER Gábor· Mar 5, 2008, 19:16 UTC · lore
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to contrib/completion/git-completion.bash +1 −1
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 8f70e1e..d138bda 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1087,7 +1087,7 @@ _git_show ()
 
 _git_stash ()
 {
-	__gitcomp 'list show apply clear'
+	__gitcomp 'save list show apply clear'
 }
 
 _git_submodule ()
-- 
1.5.4.3
SZEDER Gábor· Mar 5, 2008, 19:16 UTC · re: SZEDER Gábor · lore

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

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
Show changes to contrib/completion/git-completion.bash +16 −1
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

← back to recent threads