completion: enhance "current branch" display
Introduce GIT_PS1_DESCRIBE option you can set to "contains", "branch", or "describe" to tweak the way how a detached HEAD is described. The default behaviour is to describe only exact match with some tag (otherwise use the first 7 hexdigits) as before. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 10, 2009 at 01:56 UTC
dd42c2f015102626562da05bb290f47862ea06fb
1 file changed
+13
-2
contrib/completion/git-completion.bash
+13
-2
@@ -108,10 +108,21 @@ __git_ps1 ()
108
fi
109
110
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
111
- b="$(git describe --exact-match HEAD 2>/dev/null)" ||
111
+
112
+ b="$(
113
+ case "${GIT_PS1_DESCRIBE_STYLE-}" in
114
+ (contains)
115
+ git describe --contains HEAD ;;
116
+ (branch)
117
+ git describe --contains --all HEAD ;;
118
+ (describe)
119
+ git describe HEAD ;;
120
+ (* | default)
121
+ git describe --exact-match HEAD ;;
122
+ esac 2>/dev/null)" ||
123
+
124
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
125
b="unknown"
114
-
126
b="($b)"
127
}
128
fi