Skip to content

Commit

Permalink
bash prompt: test dirty index and worktree while on an orphan branch
Browse files Browse the repository at this point in the history
There is only a single test exercising the dirty state indicator on an
orphan branch, and in that test neither the index nor the worktree are
dirty.

Add two failing tests to check the dirty state indicator while either
the index is dirty or while both the index and the worktree are dirty
on an orphan branch, and to show that the dirtiness of the index is
not displayed in these cases (the fourth combination, i.e. clean index
and dirty worktree are impossible on an orphan branch).  Update the
existing dirty state indicator on clean orphan branch test to match
the style of the two new tests, most importantly to use 'git checkout
--orphan' instead of cd-ing into a repository that just happens to be
empty and clean.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
SZEDER Gábor authored and Jeff King committed Nov 24, 2015
1 parent af40944 commit a30d11e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions t/t9903-bash-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,36 @@ test_expect_success 'prompt - dirty status indicator - dirty index and worktree'
test_cmp expected "$actual"
'

test_expect_success 'prompt - dirty status indicator - before root commit' '
printf " (master #)" >expected &&
test_expect_success 'prompt - dirty status indicator - orphan branch - clean' '
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_failure '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_failure '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 &&
cd otherrepo &&
__git_ps1 >"$actual"
) &&
test_cmp expected "$actual"
Expand Down

0 comments on commit a30d11e

Please sign in to comment.