diff options
-rw-r--r-- | contrib/completion/git-prompt.sh | 5 | ||||
-rwxr-xr-x | t/t9903-bash-prompt.sh | 4 |
2 files changed, 4 insertions, 5 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 7a95fbdcfd..64219e631a 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -477,9 +477,8 @@ __git_ps1 () [ "$(git config --bool bash.showDirtyState)" != "false" ] then git diff --no-ext-diff --quiet || w="*" - if [ -n "$short_sha" ]; then - git diff-index --cached --quiet HEAD -- || i="+" - else + git diff --no-ext-diff --cached --quiet || i="+" + if [ -z "$short_sha" ] && [ -z "$i" ]; then i="#" fi fi diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 2c9d1f928a..af82049f82 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -285,7 +285,7 @@ test_expect_success 'prompt - dirty status indicator - orphan branch - clean' ' test_cmp expected "$actual" ' -test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty index' ' +test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index' ' printf " (orphan +)" >expected && test_when_finished "git checkout master" && git checkout --orphan orphan && @@ -296,7 +296,7 @@ test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty ind test_cmp expected "$actual" ' -test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty index and worktree' ' +test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index and worktree' ' printf " (orphan *+)" >expected && test_when_finished "git checkout master" && git checkout --orphan orphan && |