Use git-describe --exact-match in bash prompt on detached HEAD
Most of the time when I am on a detached HEAD and I am not doing a rebase or bisect operation the working directory is sitting on a tagged release of the repository. Showing the tag name instead of the commit SHA-1 is much more descriptive and a much better reminder of the state of this working directory. Now that git-describe --exact-match is available as a cheap means of obtaining the exact annotated tag or nothing at all, we can favor the annotated tag name over the abbreviated commit SHA-1. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Feb 24, 2008 at 03:07 UTC
27c578885a0b8f56430c5a24f558e2b45cf04a38
1 file changed
+4
-1
contrib/completion/git-completion.bash
+4
-1
@@ -91,7 +91,10 @@ __git_ps1 ()
91
fi
92
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
93
then
94
- b="$(cut -c1-7 $g/HEAD)..."
94
+ if ! b="$(git describe --exact-match HEAD 2>/dev/null)"
95
+ then
96
+ b="$(cut -c1-7 $g/HEAD)..."
97
+ fi
98
fi
99
fi
100