# [PATCH] bash completion: Add --autostash and --no-autostash to pull

2 messages from 2017-11-21 to 2017-11-24. Participants: Albert Astals Cid, SZEDER Gábor.
Thread: https://gitlist.dev/t/47268

## Albert Astals Cid, 2017-11-21 14:39

Subject: [PATCH] bash completion: Add --autostash and --no-autostash to pull
Message-ID: <94455771.5s97AYBuGd@yoga>
URL: https://gitlist.dev/e/94455771.5s97AYBuGd%40yoga

```
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

Signed-off-by: Albert Astals Cid <albert.astals.cid@kdab.com>
---
 contrib/completion/git-completion.bash | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-
completion.bash
index 539d7f84f..7ded58f38 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1923,6 +1923,7 @@ _git_pull ()
 	--*)
 		__gitcomp "
 			--rebase --no-rebase
+			--autostash --no-autostash
 			$__git_merge_options
 			$__git_fetch_options
 		"
-- 
2.15.0



```

## SZEDER Gábor, 2017-11-24 18:09

Subject: Re: [PATCH] bash completion: Add --autostash and --no-autostash to pull
Message-ID: <20171124180902.31253-1-szeder.dev@gmail.com>
URL: https://gitlist.dev/e/20171124180902.31253-1-szeder.dev%40gmail.com
In-Reply-To: <94455771.5s97AYBuGd@yoga>

```
> 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.


> Signed-off-by: Albert Astals Cid <albert.astals.cid@kdab.com>
> ---
>  contrib/completion/git-completion.bash | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-
> completion.bash
> index 539d7f84f..7ded58f38 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1923,6 +1923,7 @@ _git_pull ()
>  	--*)
>  		__gitcomp "
>  			--rebase --no-rebase
> +			--autostash --no-autostash
>  			$__git_merge_options
>  			$__git_fetch_options
>  		"
> -- 
> 2.15.0
> 
> 
> 

```
