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

[PATCH 3/3] stash: add test for stashing in a detached state

From
Joel Teichroeb <joel@teichroeb.net>
Date
Aug 19, 2017, 20:13 UTC
Message-ID
<20170819201326.6872-3-joel@teichroeb.net>
In-Reply-To
<20170819201326.6872-1-joel@teichroeb.net>

All that we are really testing here is that the message is correct when we are not on any branch. All other functionality is already tested elsewhere.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
---
 t/t3903-stash.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 887010c497..3b1ac1971a 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -822,6 +822,18 @@ test_expect_success 'create with multiple arguments for the message' '
 	test_cmp expect actual
 '
 
+test_expect_success 'create in a detached state' '
+	test_when_finished "git checkout master" &&
+	git checkout HEAD~1 &&
+	>foo &&
+	git add foo &&
+	STASH_ID=$(git stash create) &&
+	HEAD_ID=$(git rev-parse --short HEAD) &&
+	echo "WIP on (no branch): ${HEAD_ID} initial" >expect &&
+	git show --pretty=%s -s ${STASH_ID} >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'stash -- <pathspec> stashes and restores the file' '
 	>foo &&
 	>bar &&
-- 
2.14.1
Previous: Joel TeichroebNext: Junio C Hamano
Message 3 of 6 in “stash: add test for stash create with no files”
  1. 1/3 stash: add test for stash create with no filesJoel Teichroeb, Aug 19, 2017
  2. 2/3 stash: Add a test for when apply fails during stash branchJoel Teichroeb, Aug 19, 2017
  3. 3/3 stash: add test for stashing in a detached stateJoel Teichroeb, Aug 19, 2017
  4. Junio C HamanoAug 19, 2017
  5. Joel TeichroebAug 19, 2017
  6. Junio C HamanoAug 19, 2017

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.