git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bash completion suggests tags for git branch -D

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 2, 2021, 21:29 UTC
Message-ID
<xmqqlfc6f99m.fsf@gitster.c.googlers.com>
In-Reply-To
<CAPig+cQoCuQSyrKfE_sNCvi=Yo2035e0TOA1sOBF1HE02-kFjA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 12 quoted lines
> On Tue, Feb 2, 2021 at 12:22 PM Junio C Hamano <gitster@pobox.com> wrote:
>> From: Jeff King <peff@peff.net>
>> 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>
>
> Perhaps a Reported-by: would be appropriate?

Comparing the way I wrote the above, and a bland description of "this is broken how" plus "Reported-by:", I personally feel the former gives the credit in a more proper way, but if more people prefer the more mechanical style, I can adjust.

Here is what I queued.
--- >8 ------ >8 ------ >8 ------ >8 ------ >8 ---
From: Jeff King <peff@peff.net>
Date: Tue, 2 Feb 2021 04:02:13 -0500
Subject: [PATCH] completion: treat "branch -D" the same way as "branch -d"

The former offers not just branches but tags as completion candidates.

Mimic how "branch -d" limits its suggestion to branch names.
Reported-by: Paul Jolly <paul@myitcv.io>
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 463a3124da..ba950a247d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1438,7 +1438,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
Previous: Eric SunshineNext: Jeff King
Message 6 of 10 in “Bash completion suggests tags for git branch -D”
  1. Paul JollyFeb 2, 2021
  2. Jeff KingFeb 2, 2021
  3. Jeff KingFeb 2, 2021
  4. Junio C HamanoFeb 2, 2021
  5. Eric SunshineFeb 2, 2021
  6. Junio C HamanoFeb 2, 2021
  7. Jeff KingFeb 2, 2021
  8. Paul JollyFeb 2, 2021
  9. SZEDER GáborFeb 3, 2021
  10. completion: handle other variants of "branch -m"Jeff King, Feb 3, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.