From: Jeff King <peff@peff.net>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, Paul Jolly <paul@myitcv.io>,
git@vger.kernel.org
Subject: [PATCH] completion: handle other variants of "branch -m"
Date: Wed, 3 Feb 2021 15:59:58 -0500 [thread overview]
Message-ID: <YBsOzixRy0ahWaLN@coredump.intra.peff.net> (raw)
In-Reply-To: <20210203200047.GB1036595@szeder.dev>
On Wed, Feb 03, 2021 at 09:00:47PM +0100, SZEDER Gábor wrote:
> On Tue, Feb 02, 2021 at 09:14:39AM -0800, Junio C Hamano wrote:
> > From: Jeff King <peff@peff.net>
> > Date: Tue Feb 2 04:02:13 2021 -0500
> > Subject: [PATCH] completion: treat "branch -D" the same way as "branch -d"
> >
> > Paul Jolly noticed that the former offers not just branches but tags
> > as completion candidates. Mimic how "branch -d" limits its suggestion
> > to branch names.
>
> Uh-oh. This is a bug from my second ever commit in Git! ;)
>
> '-M' should be handled the same.
Oh, indeed. Maybe this?
-- >8 --
Subject: [PATCH] completion: handle other variants of "branch -m"
We didn't special-case "branch -M" (with a capital M) the same as
"branch -m", nor any of the "--copy" variants. As a result these offered
any ref as the next candidate, and not just branch names.
Note that I rewrapped case-arm line since it's now quite long, and
likewise the one below it for consistency. I also re-ordered the
existing "-D" to make it more obvious how the cases group together.
Signed-off-by: Jeff King <peff@peff.net>
---
We could also squash the whole thing together with the earlier "-D" as a
single fix, but it's all trivial enough that I'm not sure it's worth
spending a lot of time polishing.
contrib/completion/git-completion.bash | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ba950a247d..567e73837a 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1438,8 +1438,10 @@ _git_branch ()
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
- -d|--delete|-D|-m|--move) only_local_ref="y" ;;
- -r|--remotes) has_r="y" ;;
+ -d|-D|--delete|-m|-M|--move|-c|-C|--copy)
+ only_local_ref="y" ;;
+ -r|--remotes)
+ has_r="y" ;;
esac
((c++))
done
--
2.30.0.882.gf229bd7cc9
prev parent reply other threads:[~2021-02-03 21:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 6:01 Bash completion suggests tags for git branch -D Paul Jolly
2021-02-02 9:02 ` Jeff King
2021-02-02 9:21 ` Jeff King
2021-02-02 17:14 ` Junio C Hamano
2021-02-02 17:24 ` Eric Sunshine
2021-02-02 21:29 ` Junio C Hamano
2021-02-02 19:38 ` Jeff King
2021-02-02 20:25 ` Paul Jolly
2021-02-03 20:00 ` SZEDER Gábor
2021-02-03 20:59 ` Jeff King [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YBsOzixRy0ahWaLN@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=paul@myitcv.io \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).