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 <szeder@ira.uka.de> Signed-off-by: Jeff King <peff@peff.net>

SZEDER Gábor committed Nov 21, 2015 at 12:30 UTC a30d11ebdf78cfd664554090ce31673b01c8fd3b
1 file changed +28 -3
t/t9903-bash-prompt.sh
+28 -3
@@ -273,11 +273,36 @@ test_expect_success 'prompt - dirty status indicator - dirty index and worktree'
273 test_cmp expected "$actual"
274 '
275
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 &&
304 (
305 GIT_PS1_SHOWDIRTYSTATE=y &&
280 - cd otherrepo &&
306 __git_ps1 >"$actual"
307 ) &&
308 test_cmp expected "$actual"