2

Say I have a merge conflict in Git, and try to resolve it with vimdiff using diff3 view. Here is a screenshot:

Initial State

Now while resolving, I want to diffget once from LO see how it looks like, undo, and then diffget from RE. Another situation is that I have diffgeted from the wrong place, say LO, so I want to undo and diffget the correct one, say RE.

So first of all I do :diffget LO and get what is expected:

After <code>:diffget LO</code>

So far everything is ok, but now I want to undo the last diffget, to diffget from RE. So I undo with u and get to what I had before (though, note the highlighting difference):

After undo

And now simply diffget from RE:

After <code>diffget RE</code>

So I got one additional redundant octocat line diffgeted from RE.

Below is what I was expecting:

        +----------+------------+
        |  actual  |  expected  |
        +----------+------------+
        |    cat   |    cat     |
        |    dog   |    dog     |
   ??   |  octodog |   octodog  |
  ----> |  octocat |   octocat  |
        |  octocat |            |
        +----------+------------+

So my question is, why is this happening? And how can I achieve the behaviour I expected?

  • How do you show the bottom split ? FYW I tried the same without the bottom split and I didn't get any trouble – nobe4 Sep 14 '15 at 12:01
  • This is the diff3 view, so that the middle one is the Common Ancestor, and the bottom one is the Merge Result. I got it with git config, merge.tool=vimdiff and merge.conflictstyle=diff3. – bagrat Sep 14 '15 at 12:04
  • I see, here is a recording of a vimdiff asciinema.org/a/26318, it doesn't have the diff3 render but may do what you want. – nobe4 Sep 14 '15 at 12:07
  • @Nobe4 Thanks for your responses. Seems like running :diffupdate after :diffget ... solves the issue. – bagrat Sep 14 '15 at 12:25
  • 1
    Let us continue this discussion in chat. – nobe4 Sep 14 '15 at 12:36
1

(cf discussion)

It seems that at some point, running the diffupdate command solves the problem.

:diffupdate updates the current diff view. It changes the diff colors to match the new state between files. It also update the folds, that are displayed to keep the diff buffer relatively small.

  • 1
    Additionally, it might be helpful to have Vim automatically execute :diffget when you save the file (working copy in this case). This way, when you undo, and then save, the diff will be automatically updated. For example: autocmd BufWritePost * if &diff | diffupdate | endif – akshay Sep 16 '15 at 1:51
  • *diffUpdate.diffGet on save would be weird :p – shiro Sep 26 '17 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.