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
Junio C Hamano <gitster@pobox.com>
Date
Apr 22, 2015, 17:41 UTC
Message-ID
<xmqqa8y0f4cv.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150421225228.GB26322@peff.net>
Jeff King <peff@peff.net> writes:
Show 6 quoted lines
> Right, I am suggesting that latter: that stash should abort if the index
> has modified entries. The abort for modified working tree files is done
> by git-merge, which can be selective about which entries will be changed
> (since it knows which ones need written).  I haven't thought hard enough
> to say whether it should be doing the same for the index (i.e., whether
> this is a "merge" problem or a "stash" problem).

This is a stash problem. I've always thought that it insisted on having a clean index and a clean working tree, but apparently it doesn't, as shown in Dmitry's example sequence.

Generally speaking, any mergy operation should be done with a clean index (i.e. matches HEAD) so that any difference between the index and the HEAD after it stops in the middle is purely the result of that mergy operation, and the commands should stop when the index is not clean as a safety measure (e.g. "git am -3", "git merge") [*1*].

An especially tricky command may also insist on a clean working tree if it is not easy to guarantee that it will not clobber changes by the user when it stops in the middle (e.g. "git rebase"). But this is an escape hatch for lazy implementations ;-) It would be ideal if a command stops without doing anything when the set of paths it needs to touch would overlap the set of paths in which user has changes before the command is run (e.g. "git merge" works that way).

I think that "stash apply" requires a clean working tree for the latter reason, and does not require a clean index because it just forgot that it must do so.

Previous: Jeff KingNext: Jeff King
Message 7 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.