Merge branch 'sg/bash-prompt-dirty-orphan' into maint
Produce correct "dirty" marker for shell prompts, even when we are on an orphan or an unborn branch. * sg/bash-prompt-dirty-orphan: bash prompt: indicate dirty index even on orphan branches bash prompt: remove a redundant 'git diff' option bash prompt: test dirty index and worktree while on an orphan branch
This commit is contained in:
commit
e6ed5a438c
@ -476,10 +476,9 @@ __git_ps1 ()
|
|||||||
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
|
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
|
||||||
[ "$(git config --bool bash.showDirtyState)" != "false" ]
|
[ "$(git config --bool bash.showDirtyState)" != "false" ]
|
||||||
then
|
then
|
||||||
git diff --no-ext-diff --quiet --exit-code || w="*"
|
git diff --no-ext-diff --quiet || w="*"
|
||||||
if [ -n "$short_sha" ]; then
|
git diff --no-ext-diff --cached --quiet || i="+"
|
||||||
git diff-index --cached --quiet HEAD -- || i="+"
|
if [ -z "$short_sha" ] && [ -z "$i" ]; then
|
||||||
else
|
|
||||||
i="#"
|
i="#"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -273,11 +273,36 @@ test_expect_success 'prompt - dirty status indicator - dirty index and worktree'
|
|||||||
test_cmp expected "$actual"
|
test_cmp expected "$actual"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'prompt - dirty status indicator - before root commit' '
|
test_expect_success 'prompt - dirty status indicator - orphan branch - clean' '
|
||||||
printf " (master #)" >expected &&
|
printf " (orphan #)" >expected &&
|
||||||
|
test_when_finished "git checkout master" &&
|
||||||
|
git checkout --orphan orphan &&
|
||||||
|
git reset --hard &&
|
||||||
|
(
|
||||||
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
||||||
|
__git_ps1 >"$actual"
|
||||||
|
) &&
|
||||||
|
test_cmp expected "$actual"
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index' '
|
||||||
|
printf " (orphan +)" >expected &&
|
||||||
|
test_when_finished "git checkout master" &&
|
||||||
|
git checkout --orphan orphan &&
|
||||||
|
(
|
||||||
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
||||||
|
__git_ps1 >"$actual"
|
||||||
|
) &&
|
||||||
|
test_cmp expected "$actual"
|
||||||
|
'
|
||||||
|
|
||||||
|
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 &&
|
||||||
|
>file &&
|
||||||
(
|
(
|
||||||
GIT_PS1_SHOWDIRTYSTATE=y &&
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
||||||
cd otherrepo &&
|
|
||||||
__git_ps1 >"$actual"
|
__git_ps1 >"$actual"
|
||||||
) &&
|
) &&
|
||||||
test_cmp expected "$actual"
|
test_cmp expected "$actual"
|
||||||
|
Loading…
Reference in New Issue
Block a user