git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Fernando Ramos <greenfoo@u92.eu>
To: git@vger.kernel.org
Cc: gitster@pobox.com, seth@eseth.com, levraiphilippeblain@gmail.com,
	rogi@skylittlesystem.org
Subject: [RFC PATCH] mergetools/vimdiff: add vimdiff4 merge tool variant
Date: Tue, 19 Oct 2021 23:20:20 +0200	[thread overview]
Message-ID: <20211019212020.25385-1-greenfoo@u92.eu> (raw)

This new vimdiff4 variant of the merge-tool opens three tabs:

  - The first one contains the same panes as the standard "vimdiff" (ie.
    LOCAL, BASE and REMOTE in the top row and MERGED in the bottom row).

      ------------------------------------------
      | <TAB #1> |  TAB #2  |  TAB #3  |       |
      ------------------------------------------
      |             |           |              |
      |   LOCAL     |   BASE    |   REMOTE     |
      |             |           |              |
      ------------------------------------------
      |                                        |
      |                MERGED                  |
      |                                        |
      ------------------------------------------

      NOTE: This view is enough for 90% of the cases, but when the merge is
            somewhat complex, the three-way differences representation
            end up being messy. That is why two new tabs are added to
            show isolated one-to-one diffs.

  - The second one is a vertical diff between BASE and LOCAL

      ------------------------------------------
      |  TAB #1  | <TAB #2> |  TAB #3  |       |
      ------------------------------------------
      |                   |                    |
      |                   |                    |
      |                   |                    |
      |     BASE          |    LOCAL           |
      |                   |                    |
      |                   |                    |
      |                   |                    |
      ------------------------------------------

  - The third one is a vertical diff between BASE and REMOTE

      ------------------------------------------
      |  TAB #1  |  TAB #2  | <TAB #3> |       |
      ------------------------------------------
      |                   |                    |
      |                   |                    |
      |                   |                    |
      |     BASE          |    REMOTE          |
      |                   |                    |
      |                   |                    |
      |                   |                    |
      ------------------------------------------

Signed-off-by: Fernando Ramos <greenfoo@u92.eu>
---
 mergetools/vimdiff   | 12 +++++++++++-
 t/t7610-mergetool.sh |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index 96f6209a04..f830b1ed95 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -40,6 +40,16 @@ merge_cmd () {
 				"$LOCAL" "$REMOTE" "$MERGED"
 		fi
 		;;
+	*vimdiff4)
+		if $base_present
+		then
+			"$merge_tool_path" -f -d -c "4wincmd w | wincmd J | tabnew | edit $LOCAL | vertical diffsplit $BASE | tabnew | edit $REMOTE | vertical diffsplit $BASE | 2tabprevious" \
+				"$LOCAL" "$BASE" "$REMOTE" "$MERGED"
+		else
+			"$merge_tool_path" -f -d -c 'wincmd l' \
+				"$LOCAL" "$MERGED" "$REMOTE"
+		fi
+		;;
 	esac
 }
 
@@ -63,7 +73,7 @@ exit_code_trustable () {
 
 list_tool_variants () {
 	for prefix in '' g n; do
-		for suffix in '' 1 2 3; do
+		for suffix in '' 1 2 3 4; do
 			echo "${prefix}vimdiff${suffix}"
 		done
 	done
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index 8cc64729ad..755b4c0a4a 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -836,6 +836,7 @@ test_expect_success 'mergetool --tool-help shows recognized tools' '
 	git mergetool --tool-help >mergetools &&
 	grep vimdiff mergetools &&
 	grep vimdiff3 mergetools &&
+	grep vimdiff4 mergetools &&
 	grep gvimdiff2 mergetools &&
 	grep araxis mergetools &&
 	grep xxdiff mergetools &&
-- 
2.33.1


             reply	other threads:[~2021-10-19 21:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 21:20 Fernando Ramos [this message]
2021-10-19 22:12 ` [RFC PATCH] mergetools/vimdiff: add vimdiff4 merge tool variant Fernando Ramos
2021-10-24 22:54 ` David Aguilar
2021-10-25 18:18   ` Junio C Hamano
2021-10-25 20:13     ` Fernando Ramos
2021-10-27 16:46       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20211019212020.25385-1-greenfoo@u92.eu \
    --to=greenfoo@u92.eu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=levraiphilippeblain@gmail.com \
    --cc=rogi@skylittlesystem.org \
    --cc=seth@eseth.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).