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

[PATCH RESEND 1/2] t7508: test status output for detached HEAD after clone

From
RERoy Eldar <royeldar0@gmail.com>
Date
Mar 8, 2023, 19:20 UTC
Message-ID
<20230308192050.1291-2-royeldar0@gmail.com>
In-Reply-To
<20230308192050.1291-1-royeldar0@gmail.com>

After cloning a repository, HEAD might be detached: for example, when "--branch" specifies a non-branch (e.g. a tag). In this case, running "git status" prints 'Not currently on any branch'.

Signed-off-by: Roy Eldar <royeldar0@gmail.com>
---
 t/t7508-status.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index aed07c5b62..d279157d28 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -885,6 +885,18 @@ test_expect_success 'status shows detached HEAD properly after checking out non-
 	grep -E "HEAD detached at [0-9a-f]+" actual
 '
 
+test_expect_success 'status shows detached HEAD properly after cloning a repository' '
+	test_when_finished rm -rf upstream downstream actual &&
+
+	git init upstream &&
+	test_commit -C upstream foo &&
+	git -C upstream tag test_tag &&
+
+	git clone -b test_tag upstream downstream &&
+	git -C downstream status >actual &&
+	grep -E "Not currently on any branch." actual
+'
+
 test_expect_success 'setup status submodule summary' '
 	test_create_repo sm && (
 		cd sm &&
-- 
2.30.2
Previous: Roy EldarNext: Roy Eldar
Message 2 of 5 in “status: improve info for detached HEAD”
  1. 0/2 status: improve info for detached HEADRoy Eldar, Mar 8, 2023
  2. 1/2 t7508: test status output for detached HEAD after cloneRoy Eldar, Mar 8, 2023
  3. 2/2 status: improve info for detached HEAD after cloneRoy Eldar, Mar 8, 2023
  4. Junio C HamanoMar 8, 2023
  5. Roy EMar 10, 2023

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.