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

[PATCH 2/2] stash: Don't overwrite files that have gone from the index

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

This patch is deliberately not signed off. It feels kludgy and uses a non-portable xargs invocation.

It is designed as a starting point for discussion, that is all.
 git-stash.sh |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 908aab2..9efc544 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -87,6 +87,8 @@ create_stash () {
 			export GIT_INDEX_FILE &&
 			git read-tree -m $i_tree &&
 			git add -u &&
+			{ git diff --quiet --diff-filter=D --cached ||
+				git diff -z --name-only --diff-filter=D --cached | xargs -0 git add --ignore-errors; } &&
 			git write-tree &&
 			rm -f "$TMP-index"
 		) ) ||
-- 
1.7.1.rc0.266.gf3d756
Previous: Charles Bailey
Message 4 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.