git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug in bash completion for git rebase --onto
@ 2019-11-11 19:51 Paul Jolly
  2019-11-11 21:25 ` [PATCH] completion: learn to complete `git rebase --onto=` Denton Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Jolly @ 2019-11-11 19:51 UTC (permalink / raw)
  To: git

Hi,

The bash completion for git rebase --onto seems to have been broken by
commit 2b9bd488ae09dc89f02be7d73f3710ee2ea7325c

Previously (v2.23.0), hitting tab after

    git rebase --on

gives:

    git rebase --onto

(note trailing space) hitting tab again offers a list of potential
refs onto which to rebase.

As of 2b9bd488ae09dc89f02be7d73f3710ee2ea7325c, hitting tab after:

    git rebase --on

gives:

    git rebase --onto=

but then hitting tab again offers the current directory contents as
candidates, i.e. not git ref candidates as they should be.

Note the adding of a trailing '=' is, I think, more correct/robust
than the trailing space so I don't disagree with that change. It's
just the failure to offer git ref candidates that is the problem.

Thanks,


Paul

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

* [PATCH] completion: learn to complete `git rebase --onto=`
  2019-11-11 19:51 Bug in bash completion for git rebase --onto Paul Jolly
@ 2019-11-11 21:25 ` Denton Liu
  2019-11-12  4:46   ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Denton Liu @ 2019-11-11 21:25 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Paul Jolly

In 2b9bd488ae ("completion: teach rebase to use __gitcomp_builtin",
2019-09-12), the completion script learned to complete rebase using
__gitcomp_builtin(). However, this resulted in `--onto=` being suggested
instead of `--onto `.

Before, when there was a space, we'd start a new word and, as a result,
fallback to __git_complete_refs() and `--onto` would be completed this
way. However, now we match the `--*` case which does not know how to
offer completions for refs.

Teach _git_rebase() to complete refs in the `--onto=` case so that we
fix this regression.

Reported-by: Paul Jolly <paul@myitcv.io>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
Thanks for reporting the bug, Paul. I overlooked this case when I made
the commit that you pointed out.

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

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7b1ab46f0b..2b644056af 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2021,6 +2021,10 @@ _git_rebase ()
 		__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
 		return
 		;;
+	--onto=*)
+		__git_complete_refs --cur="${cur##--onto=}"
+		return
+		;;
 	--*)
 		__gitcomp_builtin rebase "" \
 			"$__git_rebase_interactive_inprogress_options"
-- 
2.24.0.300.g722ba42680


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

* Re: [PATCH] completion: learn to complete `git rebase --onto=`
  2019-11-11 21:25 ` [PATCH] completion: learn to complete `git rebase --onto=` Denton Liu
@ 2019-11-12  4:46   ` Junio C Hamano
  2019-11-12 18:05     ` Denton Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2019-11-12  4:46 UTC (permalink / raw)
  To: Denton Liu; +Cc: Git Mailing List, Paul Jolly

Denton Liu <liu.denton@gmail.com> writes:

> Before, when there was a space, we'd start a new word and, as a result,
> fallback to __git_complete_refs() and `--onto` would be completed this
> way. However, now we match the `--*` case which does not know how to
> offer completions for refs.

Very well explained.  Thanks, will queue.

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

* Re: [PATCH] completion: learn to complete `git rebase --onto=`
  2019-11-12  4:46   ` Junio C Hamano
@ 2019-11-12 18:05     ` Denton Liu
  2019-11-13  1:11       ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Denton Liu @ 2019-11-12 18:05 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Paul Jolly

Hi Junio,

On Tue, Nov 12, 2019 at 01:46:33PM +0900, Junio C Hamano wrote:
> Denton Liu <liu.denton@gmail.com> writes:
> 
> > Before, when there was a space, we'd start a new word and, as a result,
> > fallback to __git_complete_refs() and `--onto` would be completed this
> > way. However, now we match the `--*` case which does not know how to
> > offer completions for refs.
> 
> Very well explained.  Thanks, will queue.

Could you please queue this on the tip of
'dl/complete-rebase-and-archive' since it fixes a regression introduced
in that branch?

Thanks,

Denton

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

* Re: [PATCH] completion: learn to complete `git rebase --onto=`
  2019-11-12 18:05     ` Denton Liu
@ 2019-11-13  1:11       ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2019-11-13  1:11 UTC (permalink / raw)
  To: Denton Liu; +Cc: Git Mailing List, Paul Jolly

Denton Liu <liu.denton@gmail.com> writes:

> On Tue, Nov 12, 2019 at 01:46:33PM +0900, Junio C Hamano wrote:
>> Denton Liu <liu.denton@gmail.com> writes:
>> 
>> > Before, when there was a space, we'd start a new word and, as a result,
>> > fallback to __git_complete_refs() and `--onto` would be completed this
>> > way. However, now we match the `--*` case which does not know how to
>> > offer completions for refs.
>> 
>> Very well explained.  Thanks, will queue.
>
> Could you please queue this on the tip of
> 'dl/complete-rebase-and-archive' since it fixes a regression introduced
> in that branch?

The topic dl/complete-rebase-onto, which has this patch, is built
directly on top of that topic.  Since we may need to rewrite the
patch when further review comments come in, I'd prefer to leave it
separate from the other topic (which must not be rewritten) at least
for now.

Thanks.


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

end of thread, other threads:[~2019-11-13  1:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 19:51 Bug in bash completion for git rebase --onto Paul Jolly
2019-11-11 21:25 ` [PATCH] completion: learn to complete `git rebase --onto=` Denton Liu
2019-11-12  4:46   ` Junio C Hamano
2019-11-12 18:05     ` Denton Liu
2019-11-13  1:11       ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).