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

Re: "git stash pop" is doing an unwanted "git add" when there are conflicts.

From
Jeff King <peff@peff.net>
Date
Dec 30, 2015, 07:13 UTC
Message-ID
<20151230071319.GC26964@sigill.intra.peff.net>
In-Reply-To
<xmqq37ulhya3.fsf@gitster.mtv.corp.google.com>
On Tue, Dec 29, 2015 at 11:04:20AM -0800, Junio C Hamano wrote:
Show 7 quoted lines
> [...]
> In the above, I suggested to "git reset" when there is no conflict.
> I think this line of thinking can be followed even further to
> selectively reset the paths that were cleanly merged (which is added
> by the call to merge-recursive), leaving _only_ the conflicted paths.
> 
> Would that give us a better outcome?  I dunno.

Yes, I think that is the only sensible change to make. The only other option (besides leaving it as-is) would be to unstage _everything_ leaving conflict-marker cruft in the working tree, but no conflicts in the index. I think that's a mistake, but I won't repeat the arguments I left elsewhere in the thread.

So it's probably something like:
  git ls-files -t |
  grep -v ^M |
  cut -d ' ' -f2- |
  xargs git reset --

(modulo some quoting robustness improvements). But I guess we'd want to preserve any modifications that were originally in the index. So maybe the intersection of the files above and the output of "git diff-tree --name-only" on the stash commit.

There are probably some corner cases to look at (e.g., with "--index").

As I said, I'm not planning to work on it anytime soon, but the above may give some clues to somebody who wants to pursue it.

-Peff
Previous: Junio C HamanoNext: Alan Mackenzie
Message 8 of 10 in “"git stash pop" is doing an unwanted "git add" when there are conflicts.”
  1. Alan MackenzieDec 21, 2015
  2. Alan MackenzieDec 21, 2015
  3. Dennis KaarsemakerDec 22, 2015
  4. Jeff KingDec 22, 2015
  5. Alan MackenzieDec 24, 2015
  6. Jeff KingDec 29, 2015
  7. Junio C HamanoDec 29, 2015
  8. Jeff KingDec 30, 2015
  9. Alan MackenzieDec 29, 2015
  10. Jeff KingDec 30, 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.