summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-05-10 08:56:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-05-17 02:46:31 (GMT)
commitdd42c2f015102626562da05bb290f47862ea06fb (patch)
treedc13fff652478b84f2c09ea1fdb780e2424c3aa8
parentff790b6a4bb7fa3bbccd5ea23cefd89da900aa2e (diff)
downloadgit-dd42c2f015102626562da05bb290f47862ea06fb.zip
git-dd42c2f015102626562da05bb290f47862ea06fb.tar.gz
git-dd42c2f015102626562da05bb290f47862ea06fb.tar.bz2
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>
-rwxr-xr-xcontrib/completion/git-completion.bash15
1 files changed, 13 insertions, 2 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index be59146..dd6cd25 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -108,10 +108,21 @@ __git_ps1 ()
fi
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
- b="$(git describe --exact-match HEAD 2>/dev/null)" ||
+
+ b="$(
+ case "${GIT_PS1_DESCRIBE_STYLE-}" in
+ (contains)
+ git describe --contains HEAD ;;
+ (branch)
+ git describe --contains --all HEAD ;;
+ (describe)
+ git describe HEAD ;;
+ (* | default)
+ git describe --exact-match HEAD ;;
+ esac 2>/dev/null)" ||
+
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
b="unknown"
-
b="($b)"
}
fi