Re: Bash completion suggests tags for git branch -D
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 2, 2021, 17:14 UTC
- Message-ID
- <xmqqpn1igznk.fsf@gitster.c.googlers.com>
- In-Reply-To
- <YBkZnY8X5VyNkXkR@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 23 quoted lines
> On Tue, Feb 02, 2021 at 04:02:13AM -0500, Jeff King wrote:
>
>> > b-is-a-tag is not a branch, so should not be offered as a completion
>> > candidate in this instance.
>>
>> It looks like lowercase "-d" works. So maybe the "-d" here:
>>
>> $ sed -n '/git_branch/,/^}/p' contrib/completion/git-completion.bash | head
>> _git_branch ()
>> {
>> local i c=1 only_local_ref="n" has_r="n"
>>
>> 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" ;;
>> esac
>>
>> just needs to look for "-D", too?
>
> Oops. I meant to paste the "before" snippet, but this is obviously after
> I stuck "-D" in there. It does seem to work. :);-)
Before we forget, as you said a few times that everything you send here on Git are signed off...
-- >8 -- 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.
Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- 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 4b1f4264a6..b54113e2f9 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1447,7 +1447,7 @@ _git_branch () while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in - -d|--delete|-m|--move) only_local_ref="y" ;; + -d|--delete|-D|-m|--move) only_local_ref="y" ;; -r|--remotes) has_r="y" ;; esac ((c++))
-- 2.30.0-586-g047f30a795