aboutsummaryrefslogtreecommitdiff
path: root/contrib/completion/git-prompt.sh
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder@ira.uka.de>2013-06-24 01:55:42 +0200
committerSZEDER Gábor <szeder@ira.uka.de>2013-06-24 17:22:09 +0200
commite8f21caf94287d838cfffe8301b28fdc45480ac8 (patch)
treec86d2cb54cabeb051f221c275896477014db4501 /contrib/completion/git-prompt.sh
parent868dc1acecdb8b661e415c6c5f09db5370b35fa7 (diff)
downloadgit-e8f21caf94287d838cfffe8301b28fdc45480ac8.tar.gz
git-e8f21caf94287d838cfffe8301b28fdc45480ac8.tar.xz
bash prompt: print unique detached HEAD abbreviated object name
When describing a detached HEAD according to the $GIT_PS1_DESCRIBE environment variable fails, __git_ps1() runs 'cut -c1-7 .git/HEAD' to show the 7 hexdigits abbreviated commit object name in the prompt. Obviously, this neither respects core.abbrev nor produces a unique object name. Fix this by using 'git rev-parse --short HEAD' instead and adjust the corresponding test to use non-standard number of hexdigits. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Diffstat (limited to 'contrib/completion/git-prompt.sh')
-rw-r--r--contrib/completion/git-prompt.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 07a6218d1..3c5e62bb9 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -392,7 +392,7 @@ __git_ps1 ()
git describe --tags --exact-match HEAD ;;
esac 2>/dev/null)" ||
- b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
+ b="$(git rev-parse --short HEAD 2>/dev/null)..." ||
b="unknown"
b="($b)"
}