[PATCH 0/1] mergetools/vimdiff: add vimdiff1 merge tool variant

STALE1985d

4 messages, 2 authors, 2021-02-26 · open the first message on its own page

[PATCH 0/1] mergetools/vimdiff: add vimdiff1 merge tool variant

From: Seth House <hidden>
Date: 2021-02-14 02:29:51

Add yet another vimdiff layout variant to present the simplest possible
two-way diff when resolving conflicts.

The name is an attempt at UNIX-style humor -- vimdiff3 opens four
buffers and vimdiff2 opens three buffers so vimdiff1 should therefore
open two buffers. It also communicates that vimdiff will be used and
fits cleanly into the existing layout variant naming. That said,
suggestions welcome if that isn't as great a fit as I think it is. :)

Seth House (1):
  mergetools/vimdiff: add vimdiff1 merge tool variant

 mergetools/vimdiff | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

-- 
2.29.2

[PATCH 1/1] mergetools/vimdiff: add vimdiff1 merge tool variant

From: Seth House <hidden>
Date: 2021-02-14 02:29:51

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 <redacted>
---
 mergetools/vimdiff | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index abc8ce4ec4..96f6209a04 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -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 '' 1 2 3; do
 			echo "${prefix}vimdiff${suffix}"
 		done
 	done
-- 
2.29.2

Re: [PATCH 0/1] mergetools/vimdiff: add vimdiff1 merge tool variant

From: Philippe Blain <hidden>
Date: 2021-02-25 18:46:16

Hi Seth,

Le 2021-02-13 à 21:28, Seth House a écrit :
Add yet another vimdiff layout variant to present the simplest possible
two-way diff when resolving conflicts.

The name is an attempt at UNIX-style humor -- vimdiff3 opens four
buffers and vimdiff2 opens three buffers so vimdiff1 should therefore
open two buffers. It also communicates that vimdiff will be used and
fits cleanly into the existing layout variant naming. That said,
suggestions welcome if that isn't as great a fit as I think it is. :)
I like the name :P Slightly orthogonal though, when I first looked
at the output of 'git mergetool --tool-help', I was sort of confused by
vimdiff2 and vimdiff3 (and some others) because I looked for them in PATH and (of course)
could not find them, still Git was telling me they were available.

I think it would be good to add a short note about these variants somewhere
in Documentation/git-mergetool.txt. Might be in this patch, or not if you don't
feel like it...

Going further, we could even add a short (few words) description of each tool
and have that description show up in the output of  'git mergetool --tool-help',
something like this:

$ git mergetool --tool-help
'git mergetool --tool=<tool>' may be set to one of the following:
		emerge		Emacs (Emerge)
		opendiff	Apple FileMerge
		vimdiff		Vim (??)
		vimdiff2	Vim (3 panes)
		vimdiff3	Vim (4 panes)

Cheers,

Philippe.

Re: [PATCH 0/1] mergetools/vimdiff: add vimdiff1 merge tool variant

From: Seth House <hidden>
Date: 2021-02-26 00:30:42

On Thu, Feb 25, 2021 at 01:45:16PM -0500, Philippe Blain wrote:
I think it would be good to add a short note about these variants somewhere
in Documentation/git-mergetool.txt. Might be in this patch, or not if you don't
feel like it...

Going further, we could even add a short (few words) description of each tool
and have that description show up in the output of  'git mergetool --tool-help',
something like this:

$ git mergetool --tool-help
'git mergetool --tool=<tool>' may be set to one of the following:
		emerge		Emacs (Emerge)
		opendiff	Apple FileMerge
		vimdiff		Vim (??)
		vimdiff2	Vim (3 panes)
		vimdiff3	Vim (4 panes)
Great suggestions, thanks. A little explanation would be very helpful --
I've been confused by those variants too and wondered why I might want
to use one over another.

I'll roll those into this patch.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help