For unborn branches, it now compares the index against the empty tree.
(Just like git status does.)

Signed-off-by: Maurice Bos <m-ou...@m-ou.se>
---
 contrib/completion/git-prompt.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 7b732d2..f656838 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -407,12 +407,14 @@ __git_ps1 ()
                if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
                   [ "$(git config --bool bash.showDirtyState)" != "false" ]
                then
-                       git diff --no-ext-diff --quiet --exit-code || w="*"
-                       if [ -n "$short_sha" ]; then
-                               git diff-index --cached --quiet HEAD -- || i="+"
-                       else
+                       local treeish=HEAD
+                       if [ -z "$short_sha" ]; then
                                i="#"
+                               # the empty tree
+                               treeish=4b825dc642cb6eb9a060e54bf8d69288fbee4904
                        fi
+                       git diff --no-ext-diff --quiet --exit-code || w="*"
+                       git diff-index --cached --quiet $treeish -- || i="$i+"
                fi
                if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
                   [ -r "$g/refs/stash" ]; then
-- 
1.8.5.rc0.23.gaa27064

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to