Skip to contentSkip to conversation

mergetools/vimdiff: add vimdiff1 merge tool variant

PATCH In review Seth House 4 participants 11 messages Feb 14, 2021 – Feb 27, 2021

lore
Share & tools
lore

Seth House

author
#0 lore raw

cover mergetools/vimdiff: add vimdiff1 merge tool variant

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(-)
Signature · 1 line
2.29.2
author
#1 lore raw

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

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.

---
 mergetools/vimdiff | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
mergetools/vimdiff +12 -1
index abc8ce4ec4..96f6209a04 100644
@@ -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
Signature · 1 line
2.29.2
#2 lore raw
Quoted 12 lines · Seth House

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.

Quoted 8 lines

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

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

Any vimdiff$n + "git mergetool" users care to comment? Thanks.

Quoted 31 lines
mergetools/vimdiff +12 -1
index abc8ce4ec4..96f6209a04 100644
@@ -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
Tested-by
#3 lore raw
Quoted 19 lines · Junio C Hamano
Quoted 16 lines · Seth House

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.

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

Any vimdiff$n + "git mergetool" users care to comment? Thanks.

Nicely done, thanks Seth.

Looks good to me. FWIW,

cheers,

--
David

#5 lore raw
In reply to Seth House

Hi Seth,

Le 2021-02-13 à 21:28, Seth House a écrit :

Quoted 8 lines

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.

author
#6 lore raw
Quoted 8 lines · Philippe Blain

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:

Quoted 7 lines
$ 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.

#7 lore raw
Quoted 17 lines · Seth House
Quoted 8 lines · Philippe Blain

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:

Quoted 7 lines
$ 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)
Quoted 5 lines

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.

I'd rather see it as a completely separate patch.

author
#8 lore raw
Quoted 4 lines · Junio C Hamano
Quoted 1 line · Seth House

I'll roll those into this patch.

I'd rather see it as a completely separate patch.

Ok, will do.

Should I roll a v2 of this patch set to include David's tested-by tag even though there's no code changes?

#9 lore raw
Quoted 10 lines · Seth House
Quoted 4 lines · Junio C Hamano
Quoted 1 line · Seth House

I'll roll those into this patch.

I'd rather see it as a completely separate patch.

Ok, will do.

Should I roll a v2 of this patch set to include David's tested-by tag even though there's no code changes?

I think that is exactly what we have on sh/mergetools-vimdiff1 topic branch in 'next'.

    $ git fetch
    $ git show 'origin/next^{/^mergetools/vimdiff:}'

Thanks.

author
#10 lore raw
Quoted 2 lines · Junio C Hamano

I think that is exactly what we have on sh/mergetools-vimdiff1 topic branch in 'next'.

Oh, whoops. Thanks! I'll get into the habit of watching 'next' more closely.