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

Re: How do I resolve conflict after popping stash without adding the file to index?

From
Jeff King <peff@peff.net>
Date
Apr 21, 2015, 21:29 UTC
Message-ID
<20150421212922.GC13230@peff.net>
In-Reply-To
<553583C0.6090404@yandex.ru>
On Tue, Apr 21, 2015 at 01:54:56AM +0300, Dmitry Gutov wrote:
Show 15 quoted lines
> I'm not really sure what "higher stage entries" are, but this scenario seems
> to be a counter-example:
> 
> git init
> echo "aaaaa" > test
> git add test
> git commit -m "first"
> echo "aaa" > test
> git stash save
> echo "bbbbb" > test
> git add test
> git stash pop
> 
> Either that, or 'git stash pop' was a destructive operation, and ate the
> staged changes.

Hmm, interestingly, if you do _not_ stage the changes (i.e., drop the final "git add" there), you get:

  $ git stash pop
  error: Your local changes to the following files would be overwritten by merge:
	test
  Please, commit your changes or stash them before you can merge.
  Aborting

which makes sense. Writing conflict markers into the file would leave you in a situation where it is hard to recover the "bbbbb" content.

But we seem to skip that safety valve when the content has been staged, which seems questionable to me (technically we are slightly better off than the protected case because "bbbbb" was written to a git blob object, so you can recover it. But it may be difficult to find the correct blob in the object database).

-Peff
Previous: Dmitry GutovNext: Dmitry Gutov
Message 4 of 14 in “How do I resolve conflict after popping stash without adding the file to index?”
  1. Dmitry GutovApr 20, 2015
  2. Junio C HamanoApr 20, 2015
  3. Dmitry GutovApr 20, 2015
  4. Jeff KingApr 21, 2015
  5. Dmitry GutovApr 21, 2015
  6. Jeff KingApr 21, 2015
  7. Junio C HamanoApr 22, 2015
  8. Jeff KingApr 22, 2015
  9. Jeff KingApr 22, 2015
  10. 1/3 t3903: stop hard-coding commit sha1sJeff King, Apr 22, 2015
  11. 2/3 t3903: avoid applying onto dirty indexJeff King, Apr 22, 2015
  12. 3/3 stash: require a clean index to applyJeff King, Apr 22, 2015
  13. Junio C HamanoApr 22, 2015
  14. Jeff KingApr 22, 2015

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.