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

[PATCH 2/3] stash: Add a test for when apply fails during stash branch

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

If the return value of merge recursive is not checked, the stash could end up being dropped even though it was not applied properly

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
---
 t/t3903-stash.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index f0708ced27..887010c497 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -656,6 +656,20 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
 	git rev-parse stash@{0} --
 '
 
+test_expect_success 'stash branch should not drop the stash if the apply fails' '
+	git stash clear &&
+	git reset HEAD~1 --hard &&
+	echo foo >file &&
+	git add file &&
+	git commit -m initial &&
+	echo bar >file &&
+	git stash &&
+	echo baz >file &&
+	test_when_finished "git checkout master" &&
+	test_must_fail git stash branch new_branch stash@{0} &&
+	git rev-parse stash@{0} --
+'
+
 test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
 	git stash clear &&
 	echo 1 >subdir/subfile1 &&
-- 
2.14.1
Previous: Joel TeichroebNext: Joel Teichroeb
Message 2 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.