diff options
-rw-r--r-- | contrib/completion/git-prompt.sh | 2 | ||||
-rwxr-xr-x | t/t9903-bash-prompt.sh | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 07a6218d10..3c5e62bb9a 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)" } diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 416e6219ce..0d53aa6d69 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -50,7 +50,8 @@ test_expect_success SYMLINKS 'prompt - branch name - symlink symref' ' ' test_expect_success 'prompt - detached head' ' - printf " ((%s...))" $(git log -1 --format="%h" b1^) >expected && + printf " ((%s...))" $(git log -1 --format="%h" --abbrev=13 b1^) >expected && + test_config core.abbrev 13 && git checkout b1^ && test_when_finished "git checkout master" && __git_ps1 >"$actual" && |