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

Re: git stash pop not reapplying deletions

From
Thomas Rast <trast@student.ethz.ch>
Date
Feb 15, 2010, 15:41 UTC
Message-ID
<201002151641.19694.trast@student.ethz.ch>
In-Reply-To
<loom.20100215T152932-38@post.gmane.org>

Please don't remove the Cc list, it helps us (among other things) flag the mail that is important.

On Monday 15 February 2010 15:32:44 Steve Folly wrote:
Show 12 quoted lines
> Thomas Rast <trast <at> student.ethz.ch> writes:
> > Yes, [git stash without --index] does stage new files, but that is
> > only to help you: otherwise you could forget them before
> > committing.
> 
> But that's even more confusing - not using --index only 
> restores *some* of the index. To be honest, 
> that's not really helping - I still have to stage deletions 
> manually.
> 
> If not using --index isn't supposed to restore the index, 
> then surely it shouldn't be staging the new files?

Not sure. I personally prefer the behaviour as it is now, as I have status.showUntrackedFiles = no and would most likely forget about them. It has been that way since the introduction of git-stash, so maybe Nanako (Cc'd) can enlighten us further.

That being said, it could probably be made configurable along the lines of the patch below, or even with a config option.

diff --git i/git-stash.sh w/git-stash.sh
index 3a0685f..fc56e1b 100755
--- i/git-stash.sh
+++ w/git-stash.sh
@@ -222,12 +222,26 @@ show_stash () {
 
 apply_stash () {
 	unstash_index=
+	dont_touch_index=
 
 	while test $# != 0
 	do
 		case "$1" in
 		--index)
 			unstash_index=t
+			dont_touch_index=
+			;;
+		--index=apply)
+			unstash_index=t
+			dont_touch_index=
+			;;
+		--index=added-only)
+			unstash_index=
+			dont_touch_index=
+			;;
+		--index=none)
+			unstash_index=
+			dont_touch_index=t
 			;;
 		-q|--quiet)
 			GIT_QUIET=t
@@ -293,7 +307,7 @@ apply_stash () {
 			a="$TMP-added" &&
 			git diff-index --cached --name-only --diff-filter=A $c_tree >"$a" &&
 			git read-tree --reset $c_tree &&
-			git update-index --add --stdin <"$a" ||
+			(test -n "$dont_touch_index" || git update-index --add --stdin <"$a") ||
 				die "Cannot unstage modified files"
 			rm -f "$a"
 		fi
-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Steve FollyNext: Thomas Rast
Message 4 of 8 in “git stash pop not reapplying deletions”
  1. Steve FollyFeb 14, 2010
  2. Thomas RastFeb 14, 2010
  3. Steve FollyFeb 15, 2010
  4. Thomas RastFeb 15, 2010
  5. stash pop: remove 'apply' options during 'drop' invocationThomas Rast, Feb 15, 2010
  6. Stephen BoydFeb 15, 2010
  7. Steve FollyFeb 15, 2010
  8. Junio C HamanoFeb 16, 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.