public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Fernando Ramos <greenfoo@u92•eu>
To: git@vger•kernel.org
Cc: "D . Ben Knoble" <ben.knoble+github@gmail•com>,
	Fernando Ramos <greenfoo@u92•eu>,
	Junio C Hamano <gitster@pobox•com>,
	kawarimidoll <kawarimidoll+git@gmail•com>
Subject: [PATCH 1/2] mergetools: vimdiff: fix layout where REMOTE is the target
Date: Tue, 25 Mar 2025 23:23:10 +0100	[thread overview]
Message-ID: <20250325222311.400748-2-greenfoo@u92.eu> (raw)
In-Reply-To: <20250325222311.400748-1-greenfoo@u92.eu>

"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>
---
 mergetools/vimdiff | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index ffc9be86c8..0e3785d230 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -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
-- 
2.49.0


  reply	other threads:[~2025-03-25 22:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-25 22:23 [PATCH 0/2] Fix mergetool.vimdiff.layout when "@" is used on REMOTE Fernando Ramos
2025-03-25 22:23 ` Fernando Ramos [this message]
2025-03-29  0:23   ` [PATCH 1/2] mergetools: vimdiff: fix layout where REMOTE is the target D. Ben Knoble
2025-03-29 20:46     ` Junio C Hamano
2025-03-25 22:23 ` [PATCH 2/2] mergetools: vimdiff: add tests for layout with REMOTE as " Fernando Ramos
2025-03-26 10:10 ` [PATCH 0/2] Fix mergetool.vimdiff.layout when "@" is used on REMOTE Fernando

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250325222311.400748-2-greenfoo@u92.eu \
    --to=greenfoo@u92$(echo .)eu \
    --cc=ben.knoble+github@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=kawarimidoll+git@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox