Skip to content

Commit a30d11e

Browse files
szederpeff
authored andcommitted
bash prompt: test dirty index and worktree while on an orphan branch
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent af40944 commit a30d11e

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

t/t9903-bash-prompt.sh

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,36 @@ test_expect_success 'prompt - dirty status indicator - dirty index and worktree'
273273
test_cmp expected "$actual"
274274
'
275275

276-
test_expect_success 'prompt - dirty status indicator - before root commit' '
277-
printf " (master #)" >expected &&
276+
test_expect_success 'prompt - dirty status indicator - orphan branch - clean' '
277+
printf " (orphan #)" >expected &&
278+
test_when_finished "git checkout master" &&
279+
git checkout --orphan orphan &&
280+
git reset --hard &&
281+
(
282+
GIT_PS1_SHOWDIRTYSTATE=y &&
283+
__git_ps1 >"$actual"
284+
) &&
285+
test_cmp expected "$actual"
286+
'
287+
288+
test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty index' '
289+
printf " (orphan +)" >expected &&
290+
test_when_finished "git checkout master" &&
291+
git checkout --orphan orphan &&
292+
(
293+
GIT_PS1_SHOWDIRTYSTATE=y &&
294+
__git_ps1 >"$actual"
295+
) &&
296+
test_cmp expected "$actual"
297+
'
298+
299+
test_expect_failure 'prompt - dirty status indicator - orphan branch - dirty index and worktree' '
300+
printf " (orphan *+)" >expected &&
301+
test_when_finished "git checkout master" &&
302+
git checkout --orphan orphan &&
303+
>file &&
278304
(
279305
GIT_PS1_SHOWDIRTYSTATE=y &&
280-
cd otherrepo &&
281306
__git_ps1 >"$actual"
282307
) &&
283308
test_cmp expected "$actual"

0 commit comments

Comments
 (0)