git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] bash prompt: test dirty index and worktree while on an orphan branch

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Nov 21, 2015, 11:30 UTC
Message-ID
<1448105409-4494-1-git-send-email-szeder@ira.uka.de>

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 forth 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>
---
 t/t9903-bash-prompt.sh | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 6b68777b98..2c9d1f928a 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -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"
-- 
2.6.3.402.geb6a0f7
Next: SZEDER Gábor
Message 1 of 4 in “bash prompt: test dirty index and worktree while on an orphan branch”
  1. 1/3 bash prompt: test dirty index and worktree while on an orphan branchSZEDER Gábor, Nov 21, 2015
  2. 2/3 bash prompt: remove a redundant command line optionSZEDER Gábor, Nov 21, 2015
  3. 2/3 bash prompt: remove a redundant 'git diff' optionSZEDER Gábor, Nov 21, 2015
  4. 3/3 bash prompt: indicate dirty index even on orphan branchesSZEDER Gábor, Nov 21, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.