Skip to contentSkip to conversation

Update BASH completions

PATCH Superseded Paul Wagland 3 participants 10 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover Update BASH completions

While playing around git stash I noticed that some options were missing. I have updated these in the BASH completions file. Note that this is not a comprehensive review, but adds the options that I use in git-stash, and a nearby missing option.

Paul Wagland (2):
Update the flags for git show-branch
Fix up the arguments for git stash. This adds the branch to the branch
subcommand, and adds the missing options to save and drop commands

 contrib/completion/git-completion.bash | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

--
2.7.0

#1 lore raw

PATCH 1/2] Update the flags for git show-branch

---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/completion/git-completion.bash +1 -1
index ab4da7f..63754bc 100644
@@ -2369,7 +2369,7 @@ _git_show_branch ()
 	case "$cur" in
 	--*)
 		__gitcomp "
-			--all --remotes --topo-order --current --more=
+			--all --remotes --topo-order --date-order --current --more=
 			--list --independent --merge-base --no-name
 			--color --no-color
 			--sha1-name --sparse --topics --reflog

--
2.7.0

#3 lore raw

PATCH 2/2 Fix up the arguments for git stash.

In reply to Paul Wagland
---
 contrib/completion/git-completion.bash | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
contrib/completion/git-completion.bash +14 -3
index 63754bc..043d5bb 100644
@@ -2382,7 +2382,7 @@ _git_show_branch ()
 
 _git_stash ()
 {
-	local save_opts='--keep-index --no-keep-index --quiet --patch'
+	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
 	local subcommands='save list show apply clear drop pop create branch'
 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
@@ -2404,9 +2404,20 @@ _git_stash ()
 		apply,--*|pop,--*)
 			__gitcomp "--index --quiet"
 			;;
-		show,--*|drop,--*|branch,--*)
+		drop,--*)
+			__gitcomp "--quiet"
 			;;
-		show,*|apply,*|drop,*|pop,*|branch,*)
+		show,--*|branch,--*)
+			;;
+		branch,*)
+			if [ $cword -eq 3 ]; then
+			__gitcomp_nl "$(__git_refs)";
+			else
+				__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+						| sed -n -e 's/:.*//p')"
+			fi
+			;;
+		show,*|apply,*|drop,*|pop,*)
 			__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
 					| sed -n -e 's/:.*//p')"
 			;;
Signature · 1 line
2.7.0
#4 lore raw

Re: [PATCH 2/2] Fix up the arguments for git stash.

In reply to Paul Wagland
Quoted 2 lines · Paul Wagland

---

This needs a better explanation than just "Fix up" in the title. What is broken in the current behaviour and what is the more desired behaviour?

Thanks.

Quoted 39 lines
 contrib/completion/git-completion.bash | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
contrib/completion/git-completion.bash +14 -3
index 63754bc..043d5bb 100644
@@ -2382,7 +2382,7 @@ _git_show_branch ()
 
 _git_stash ()
 {
-	local save_opts='--keep-index --no-keep-index --quiet --patch'
+	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
 	local subcommands='save list show apply clear drop pop create branch'
 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
@@ -2404,9 +2404,20 @@ _git_stash ()
 		apply,--*|pop,--*)
 			__gitcomp "--index --quiet"
 			;;
-		show,--*|drop,--*|branch,--*)
+		drop,--*)
+			__gitcomp "--quiet"
 			;;
-		show,*|apply,*|drop,*|pop,*|branch,*)
+		show,--*|branch,--*)
+			;;
+		branch,*)
+			if [ $cword -eq 3 ]; then
+			__gitcomp_nl "$(__git_refs)";
+			else
+				__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+						| sed -n -e 's/:.*//p')"
+			fi
+			;;
+		show,*|apply,*|drop,*|pop,*)
 			__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
 					| sed -n -e 's/:.*//p')"
 			;;
#5 lore raw

Re: [PATCH 2/2] Fix up the arguments for git stash.

Fair enough. I'll re-roll the patches with improved comments, and get these out to the list today.

Cheers,
Paul

Sent from my iPhone

Quoted 12 lines · Junio C Hamano
Quoted 2 lines · Paul Wagland

---

This needs a better explanation than just "Fix up" in the title. What is broken in the current behaviour and what is the more desired behaviour?

Thanks.

#6 lore raw

v2 cover Update BASH completions

In reply to Paul Wagland

While playing around git stash I noticed that some options were missing. I have updated these in the BASH completions file. Note that this is not a comprehensive review, but adds the options that I use in git-stash, and a nearby missing option.

This re-roll doesn't change the code, but updates the commit comments to make it clearer what each change is doing.

Paul Wagland (2):
Update the flags for git show-branch
Fix up the arguments for git stash. This adds the branch to the branch
subcommand, and adds the missing options to save and drop commands

 contrib/completion/git-completion.bash | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

--
2.7.0

#7 lore raw

PATCH v2 1/2 completion: complete show-branch "--date-order"

---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/completion/git-completion.bash +1 -1
index ab4da7f..63754bc 100644
@@ -2369,7 +2369,7 @@ _git_show_branch ()
 	case "$cur" in
 	--*)
 		__gitcomp "
-			--all --remotes --topo-order --current --more=
+			--all --remotes --topo-order --date-order --current --more=
 			--list --independent --merge-base --no-name
 			--color --no-color
 			--sha1-name --sparse --topics --reflog
Signature · 1 line
2.7.0
#8 lore raw

PATCH v2 2/4 completion: update completion arguments for stash

In reply to Paul Wagland

Add --all and --include-untracked to the git stash save completions. Add --quiet to the git stash drop completions.
Update git stash branch so that the first argument expands out to the possible branch names, and the other arguments expand to the stash names.

---
 contrib/completion/git-completion.bash | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
contrib/completion/git-completion.bash +14 -3
index 63754bc..043d5bb 100644
@@ -2382,7 +2382,7 @@ _git_show_branch ()
 
 _git_stash ()
 {
-	local save_opts='--keep-index --no-keep-index --quiet --patch'
+	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
 	local subcommands='save list show apply clear drop pop create branch'
 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
@@ -2404,9 +2404,20 @@ _git_stash ()
 		apply,--*|pop,--*)
 			__gitcomp "--index --quiet"
 			;;
-		show,--*|drop,--*|branch,--*)
+		drop,--*)
+			__gitcomp "--quiet"
 			;;
-		show,*|apply,*|drop,*|pop,*|branch,*)
+		show,--*|branch,--*)
+			;;
+		branch,*)
+		  if [ $cword -eq 3 ]; then
+  			__gitcomp_nl "$(__git_refs)";
+			else
+				__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+						| sed -n -e 's/:.*//p')"
+			fi
+			;;
+		show,*|apply,*|drop,*|pop,*)
 			__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
 					| sed -n -e 's/:.*//p')"
 			;;
Signature · 1 line
2.7.0
#9 lore raw

PATCH 1/1 completion: fix mis-indentation in _git_stash()

---
 contrib/completion/git-completion.bash | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
contrib/completion/git-completion.bash +2 -2
index 45ec47f2b1b4..e3918c87e3ad 100644
@@ -2415,8 +2415,8 @@ _git_stash ()
 		show,--*|branch,--*)
 			;;
 		branch,*)
-		  if [ $cword -eq 3 ]; then
-			__gitcomp_nl "$(__git_refs)";
+			if [ $cword -eq 3 ]; then
+				__gitcomp_nl "$(__git_refs)";
 			else
 				__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
 						| sed -n -e 's/:.*//p')"
Signature · 1 line
2.7.1.384.g61d9461