From a534cf4f4d5ac58b91112fc12478d8a32e348152 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 2 Feb 2021 04:02:13 -0500 Subject: [PATCH 1/3] 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 Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- 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 463a3124da0..ba950a247d3 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++)) From bca362c1f94164f23e1c9b5cf833804d46315cbe Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 3 Feb 2021 15:59:58 -0500 Subject: [PATCH 2/3] 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 Signed-off-by: Junio C Hamano --- 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 ba950a247d3..567e73837ac 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 From 27dc071b9a11e953ea7d73bfdf6103940d039215 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 3 Feb 2021 16:07:32 -0500 Subject: [PATCH 3/3] doc/git-branch: fix awkward wording for "-c" The description for "-c" is hard to parse. I think the big issue is lack of commas, but I've also reordered the words to keep the main focus point of "instead of renaming, copy" together. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- Documentation/git-branch.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index adaa1782a8b..eb815c22484 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -78,8 +78,8 @@ renaming. If exists, -M must be used to force the rename to happen. The `-c` and `-C` options have the exact same semantics as `-m` and -`-M`, except instead of the branch being renamed it along with its -config and reflog will be copied to a new name. +`-M`, except instead of the branch being renamed, it will be copied to a +new name, along with its config and reflog. With a `-d` or `-D` option, `` will be deleted. You may specify more than one branch for deletion. If the branch currently