git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* [PATCH] completion: fix completing stashes with "show -p"
@ 2020-05-21 14:21 Ville Skyttä
  2020-05-21 18:24 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Ville Skyttä @ 2020-05-21 14:21 UTC (permalink / raw)
  To: git

Regression in df70b190bdd2add42a906819f9d41dbf91cf0809

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 70ad04e1b2..8dc4ad0e0d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2782,7 +2782,7 @@ _git_stash ()
 	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
 	local subcommands='push list show apply clear drop pop create branch'
 	local subcommand="$(__git_find_on_cmdline "$subcommands save")"
-	if [ -n "$(__git_find_on_cmdline "-p")" ]; then
+	if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then
 		subcommand="push"
 	fi
 	if [ -z "$subcommand" ]; then
-- 
2.27.0.rc1.dirty


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] completion: fix completing stashes with "show -p"
  2020-05-21 14:21 [PATCH] completion: fix completing stashes with "show -p" Ville Skyttä
@ 2020-05-21 18:24 ` Junio C Hamano
  2020-05-21 18:31   ` Ville Skyttä
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2020-05-21 18:24 UTC (permalink / raw)
  To: Ville Skyttä; +Cc: git

Ville Skyttä <ville.skytta@iki.fi> writes:

> Regression in df70b190bdd2add42a906819f9d41dbf91cf0809

That's not very helpful to readers.

Something like this?  I am merely guessing why you thought this
change is a good one, but that is what the proposed log message
is supposed to do.

    df70b190 (completion: make stash -p and alias for stash push -p,
    2018-04-20) wanted to make sure "git stash -p <TAB>" offers the same
    completion as "git stash push -p <TAB>", but it did so by forcing
    the $subcommand to be "push" whenever then "-p" option is found on
    the command line.  

    This harms any subcommand that can take the "-p" option---even when
    the subcommand is explicitly given, e.g. "git stash show -p", the
    code added by the change would overwrite the $subcommand the user
    gave us.

    Fix it by making sure that the defaulting to "push" happens only
    when there is no $subcommand given yet.

Thanks.

>
> Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
> ---
>  contrib/completion/git-completion.bash | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 70ad04e1b2..8dc4ad0e0d 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2782,7 +2782,7 @@ _git_stash ()
>  	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
>  	local subcommands='push list show apply clear drop pop create branch'
>  	local subcommand="$(__git_find_on_cmdline "$subcommands save")"
> -	if [ -n "$(__git_find_on_cmdline "-p")" ]; then
> +	if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then
>  		subcommand="push"
>  	fi
>  	if [ -z "$subcommand" ]; then

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] completion: fix completing stashes with "show -p"
  2020-05-21 18:24 ` Junio C Hamano
@ 2020-05-21 18:31   ` Ville Skyttä
  0 siblings, 0 replies; 3+ messages in thread
From: Ville Skyttä @ 2020-05-21 18:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Thu, 21 May 2020 at 21:24, Junio C Hamano <gitster@pobox.com> wrote:
>
> Ville Skyttä <ville.skytta@iki.fi> writes:
>
> > Regression in df70b190bdd2add42a906819f9d41dbf91cf0809
>
> That's not very helpful to readers.
>
> Something like this?  I am merely guessing why you thought this
> change is a good one, but that is what the proposed log message
> is supposed to do.

Excellent guess and wording. Will copy verbatim and re-submit.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 14:21 [PATCH] completion: fix completing stashes with "show -p" Ville Skyttä
2020-05-21 18:24 ` Junio C Hamano
2020-05-21 18:31   ` Ville Skyttä

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git