[PATCH 2/2] bash: git-branch -d and -m lists only local branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



But still all branches are listed, if -r is present

Signed-off-by: SZEDER Gábor <szeder@xxxxxxxxxx>
---
 contrib/completion/git-completion.bash |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 8d6733a..49e6df0 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -506,6 +506,17 @@ _git_bisect ()
 
 _git_branch ()
 {
+	local i c=1 only_local_ref="n" has_r="n"
+
+	while [ $c -lt $COMP_CWORD ]; do
+		i="${COMP_WORDS[c]}"
+		case "$i" in
+		-d|-m)	only_local_ref="y" ;;
+		-r)	has_r="y" ;;
+		esac
+		c=$((++c))
+	done
+
 	case "${COMP_WORDS[COMP_CWORD]}" in
 	--*=*)	COMPREPLY=() ;;
 	--*)
@@ -514,7 +525,13 @@ _git_branch ()
 			--track --no-track
 			"
 		;;
-	*)	__gitcomp "$(__git_refs)" ;;
+	*)
+		if [ $only_local_ref = "y" -a $has_r = "n" ]; then
+			__gitcomp "$(__git_heads)"
+		else
+			__gitcomp "$(__git_refs)"
+		fi
+		;;
 	esac
 }
 
-- 
1.5.4.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux