]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mergetools: vimdiff: fix layout where REMOTE is the target
authorFernando Ramos <greenfoo@u92.eu>
Tue, 25 Mar 2025 22:23:10 +0000 (23:23 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Mar 2025 23:22:32 +0000 (16:22 -0700)
"mergetool.vimdiff.layout" is used to define the vim layout (ie. how
windows, tabs and buffers are physically organized) when resolving
conflicts.

For example, if we set it to this:

    "(LOCAL,BASE,REMOTE)/MERGED"

...vim will open and show this layout:

    ------------------------------------------
    |             |           |              |
    |   LOCAL     |   BASE    |   REMOTE     |
    |             |           |              |
    ------------------------------------------
    |                                        |
    |                MERGED                  |
    |                                        |
    ------------------------------------------

By default, whatever ends up been written to the "MERGED" window will
become the file which conflict we are resolving.

However, it is possible to use the "@" symbol to specify a different
one.  For example, if we use this slightly different version of the
previously used string:

    "(LOCAL,BASE,@REMOTE)/MERGED"

...then the user should proceed to edit the contents of the top right
window (instead of the bottom window) as *that* is what will become the
conflicts free file once vim is closed.

Before this commit, the "@" marker worked for all targets *except* for
"REMOTE". In other words, these worked as expected:

    "(@LOCAL,BASE,REMOTE)/MERGED"
    "(LOCAL,@BASE,REMOTE)/MERGED"
    "(LOCAL,BASE,REMOTE)/@MERGED"

...but this didn't:

    "(LOCAL,BASE,@REMOTE)/MERGED"

This commit fixes that.

Reported-by: kawarimidoll <kawarimidoll+git@gmail.com>
Suggested-by: D. Ben Knoble <ben.knoble@gmail.com>
Signed-off-by: Fernando Ramos <greenfoo@u92.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetools/vimdiff

index f8ad6b35d4dbde267d3defcf5bcd78b92c779fab..e536ab6bfef8de7362347926d026a336ce871d08 100644 (file)
@@ -305,6 +305,9 @@ gen_cmd () {
        elif echo "$LAYOUT" | grep @BASE >/dev/null
        then
                FINAL_TARGET="BASE"
+       elif echo "$LAYOUT" | grep @REMOTE >/dev/null
+       then
+               FINAL_TARGET="REMOTE"
        else
                FINAL_TARGET="MERGED"
        fi