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

[PATCH 1/2] stash bug: stash can lose data in a file removed from the index

From
Charles Bailey <charles@hashpling.org>
Date
Apr 10, 2010, 18:14 UTC
Message-ID
<1270923241-14383-1-git-send-email-charles@hashpling.org>
In-Reply-To
<v2w918f64e01004101104xd4f1b4eciec01d2e87691ee72@mail.gmail.com>

If a file is removed from the index and then modified in the working tree then stash will discard the working tree file with no way to recover the changes.

This can might be done in one of a number of ways.

git rm file vi file # edit a new version git stash

or with git mv

git mv file newfile vi file # make a new file with the old name git stash

Signed-off-by: Charles Bailey <charles@hashpling.org>
---
 t/t3903-stash.sh |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 476e5ec..c85bf44 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -228,4 +228,13 @@ test_expect_success 'stash --invalid-option' '
 	test bar,bar2 = $(cat file),$(cat file2)
 '
 
+test_expect_failure 'stash git rm' '
+    git reset --hard &&
+	git rm file &&
+	echo bar7 > file &&
+	git stash &&
+	git stash apply &&
+	test bar7 = $(cat file)
+'
+
 test_done
-- 
1.7.1.rc0.266.gf3d756
Previous: Khaled al HabacheNext: Charles Bailey
Message 2 of 4 in “Strange case with stash”
  1. Khaled al HabacheApr 10, 2010
  2. 1/2 stash bug: stash can lose data in a file removed from the indexCharles Bailey, Apr 10, 2010
  3. Charles BaileyApr 12, 2010
  4. 2/2 stash: Don't overwrite files that have gone from the indexCharles Bailey, Apr 10, 2010

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.