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