]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mergetools/vimdiff: add vimdiff1 merge tool variant
authorSeth House <seth@eseth.com>
Sun, 14 Feb 2021 02:28:40 +0000 (19:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Feb 2021 19:37:13 +0000 (11:37 -0800)
This adds yet another vimdiff/gvimdiff variant and presents conflicts as
a two-way diff between 'LOCAL' and 'REMOTE'. 'MERGED' is not opened
which deviates from the norm so usage text is echoed as a Vim message on
startup that instructs the user with how to proceed and how to abort.

Vimdiff is well-suited to two-way diffs so this is an option for a more
simple, more streamlined conflict resolution. For example: it is
difficult to communicate differences across more than two files using
only syntax highlighting; default vimdiff commands to get and put
changes between buffers do not need the user to manually specify
a source or destination buffer when only using two buffers.

Like other merge tools that directly compare 'LOCAL' with 'REMOTE', this
tool will benefit when paired with the new `mergetool.hideResolved`
setting.

Signed-off-by: Seth House <seth@eseth.com>
Tested-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetools/vimdiff

index abc8ce4ec44e190812ba46b39b8ba2dec1cc14fe..96f6209a04106fbe8b66e30d5fefd0c8e92fb685 100644 (file)
@@ -15,6 +15,17 @@ merge_cmd () {
                                "$LOCAL" "$MERGED" "$REMOTE"
                fi
                ;;
+       *vimdiff1)
+               "$merge_tool_path" -f -d \
+                       -c 'echon "Resolve conflicts leftward then save. Use :cq to abort."' \
+                       "$LOCAL" "$REMOTE"
+               ret="$?"
+               if test "$ret" -eq 0
+               then
+                       cp -- "$LOCAL" "$MERGED"
+               fi
+               return "$ret"
+               ;;
        *vimdiff2)
                "$merge_tool_path" -f -d -c 'wincmd l' \
                        "$LOCAL" "$MERGED" "$REMOTE"
@@ -52,7 +63,7 @@ exit_code_trustable () {
 
 list_tool_variants () {
        for prefix in '' g n; do
-               for suffix in '' 2 3; do
+               for suffix in '' 2 3; do
                        echo "${prefix}vimdiff${suffix}"
                done
        done