Skip to contentSkip to conversation

bash completion: Add --autostash and --no-autostash to pull

PATCH In review Albert Astals Cid 2 participants 2 messages Nov 21, 2017 – Nov 24, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bash completion: Add --autostash and --no-autostash to pull

Ideally we should only autocomplete if pull has --rebase since they only work with it but could not figure out how to do that and the error message of doing git pull --autostash points out that you need --rebase so i guess it's good enough

---
 contrib/completion/git-completion.bash | 1 +
 1 file changed, 1 insertion(+)
contrib/completion/git- renamed from contrib/completion/git-completion.bash +0 -0

completion.bash
index 539d7f84f..7ded58f38 100644

contrib/completion/git-completion.bash +1 -0
@@ -1923,6 +1923,7 @@ _git_pull ()
 	--*)
 		__gitcomp "
 			--rebase --no-rebase
+			--autostash --no-autostash
 			$__git_merge_options
 			$__git_fetch_options
 		"
Signature · 1 line
2.15.0
#1 lore raw
Quoted 4 lines

Ideally we should only autocomplete if pull has --rebase since they only work with it but could not figure out how to do that and the error message of doing git pull --autostash points out that you need --rebase so i guess it's good enough

You could use the completion script's __git_find_on_cmdline() helper function to easily check whether the '--rebase' option is already present on the command line.

Having said that, I don't think we should go there, it feels that's trying to be overly and unnecessarily clever. After all, the order of command line options doesn't matter, and 'git pull --autostash --rebase' is a perfectly legit command.

Quoted 23 lines
---
 contrib/completion/git-completion.bash | 1 +
 1 file changed, 1 insertion(+)
contrib/completion/git- renamed from contrib/completion/git-completion.bash +0 -0

completion.bash
index 539d7f84f..7ded58f38 100644

contrib/completion/git-completion.bash +1 -0
@@ -1923,6 +1923,7 @@ _git_pull ()
 	--*)
 		__gitcomp "
 			--rebase --no-rebase
+			--autostash --no-autostash
 			$__git_merge_options
 			$__git_fetch_options
 		"
Signature · 1 line
2.15.0