All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] mergetools/vimdiff: add vimdiff4 merge tool variant
@ 2021-10-19 21:20 Fernando Ramos
  2021-10-19 22:12 ` Fernando Ramos
  2021-10-24 22:54 ` David Aguilar
  0 siblings, 2 replies; 6+ messages in thread
From: Fernando Ramos @ 2021-10-19 21:20 UTC (permalink / raw)
  To: git; +Cc: gitster, seth, levraiphilippeblain, rogi

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-27 16:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 21:20 [RFC PATCH] mergetools/vimdiff: add vimdiff4 merge tool variant Fernando Ramos
2021-10-19 22:12 ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.