mirror of
https://github.com/git/git.git
synced 2024-10-29 21:37:53 +01:00
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>
This commit is contained in:
parent
2c33f75754
commit
27c578885a
1 changed files with 4 additions and 1 deletions
|
@ -90,10 +90,13 @@ __git_ps1 ()
|
|||
r="|BISECTING"
|
||||
fi
|
||||
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
|
||||
then
|
||||
if ! b="$(git describe --exact-match HEAD 2>/dev/null)"
|
||||
then
|
||||
b="$(cut -c1-7 $g/HEAD)..."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
printf "$1" "${b##refs/heads/}$r"
|
||||
|
|
Loading…
Reference in a new issue