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

From: Junio C Hamano <[email-masked]>
Date: Tue, 29 Dec 2015 11:04:20 -0800

Jeff King <[email-masked]> writes:

> Yeah, I think I agree. But keep in mind that we have to mention the
> conflicts _somewhere_, so we're going to touch the index regardless (and
> the user is going to have to erase the conflicts in the index
> eventually, either with `git add` or `git reset`).

I do not think there is much we can do at this point in time (but
notice that I did say "much", and didn't say "anything").

The way we replay any potentially conflicting change and present the
result to the end user in Git is uniformly to add the cleanly
applied parts to the index while leaving the conflicted ones as
unmerged index entries, but "git stash apply/pop" does not follow
this pattern.  I think this is partly because the command is also
used to "stash away" a work-in-progress changes to the index, and
avoiding to touch the index with the changes in the working tree
would more closely match the behaviour of the command when there is
no conflict.

I notice that I said the same thing long time ago, i.e. in the
initial round of review:

  http://article.gmane.org/gmane.comp.version-control.git/50749

| However, I think it is a bit counterintuitive to update the
| working tree change to the index if the merge did not conflict.
| It might be better to run an equivalent of "git reset", so that
| after "git save restore", the user can say "git diff" (not "git
| diff HEAD") to view the local changes.  Perhaps...

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.

>> Are there any prospects of this getting fixed?
>
> Somebody needs to write a patch. I am not 100% convinced that it
> _should_ be fixed, but I am leaning that way. But I am not planning to
> work on it myself anytime soon. The best way to get more discussion
> going is to post a patch. :)