[RFC PATCH] mergetools/vimdiff: add vimdiff4 merge tool variant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux