Subject: Re: bug#20292: 24.5; Saving Git-controlled file with merge conflicts after "stash pop" stages the file

From: Eli Zaretskii <[email-masked]>
Date: Wed, 22 Apr 2015 12:16:28 +0300

> Date: Wed, 22 Apr 2015 04:47:44 -0400
> From: Richard Stallman <[email-masked]>
> CC: [email-masked], [email-masked], [email-masked]
> 
>   > >> Then my vote is for using "git add FILE" with conflicts during a
>   > >> merge, and "git reset HEAD FILE" with conflicts during "stash pop".
>   > >> I think this is the simplest solution and is easy to implement with
>   > >> minimal changes.
>   > >
>   > > Fine by me,
> 
>   > I've pushed this, together with the choosing logic suggested previously. 
>   > Apparently it's the best we can do.
> 
> Could you describe the new behavior that you have implemented?

The new behavior changes what Emacs does when you save a file which
had conflicts that you resolved:

  . if the conflicts were due to a merge (which includes the automatic
    merge done by "git pull"), the behavior is as before: Emacs stages
    the file for commit by running "git add FILE"

  . if the conflicts were due to something else (which includes
    conflicts during "git stash pop"; not sure if there are other
    non-merge situations that create conflicts), then the new behavior
    is to run "git reset FILE", which leaves any changes in FILE
    uncommitted (and not staged), thus restoring the status of FILE
    before "git stash save"

The one thing to remember is that after saving the file whose
conflicts were resolved, you should type "C-x v v" to commit it in the
first case, and do nothing in the second.