threads / patch / 55145

patchmergetools/vimdiff: add vimdiff1 merge tool variant

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

## tl;dr

11 messages between Feb 14, 2021 and Feb 27, 2021. Diffs are folded; open one to read it.

replies: 10people: 4as markdown or json

Seth House· Feb 14, 2021, 02:28 UTC · lore

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
Seth House· Feb 14, 2021, 02:28 UTC · re: Seth House · lore

[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.

Signed-off-by: Seth House <seth@eseth.com>
---
 mergetools/vimdiff | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
Show changes to mergetools/vimdiff +12 −1
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
Junio C Hamano· Feb 16, 2021, 18:38 UTC · re: Seth House · lore

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

Seth House <seth@eseth.com> writes:
Show 20 quoted lines
> 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>
> ---
>  mergetools/vimdiff | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
Any vimdiff$n + "git mergetool" users care to comment?  Thanks.
Show 31 quoted lines
> 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
David Aguilar· Feb 23, 2021, 18:55 UTC · re: Junio C Hamano · lore

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

On Tue, Feb 16, 2021 at 10:42 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 25 quoted lines
>
> Seth House <seth@eseth.com> writes:
>
> > 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>
> > ---
> >  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,
Tested-by: David Aguilar <davvid@gmail.com>
cheers,

-- David

Seth House· Feb 25, 2021, 16:02 UTC · re: David Aguilar · lore

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

On Tue, Feb 23, 2021 at 10:55:00AM -0800, David Aguilar wrote:
> Looks good to me.  FWIW,
> Tested-by: David Aguilar <davvid@gmail.com>
Thank you for testing that, David.
Philippe Blain· Feb 25, 2021, 18:45 UTC · re: Seth House · lore

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

Hi Seth,
Le 2021-02-13 à 21:28, Seth House a écrit :
Show 8 quoted 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.
Seth House· Feb 26, 2021, 00:29 UTC · re: Philippe Blain · lore

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

On Thu, Feb 25, 2021 at 01:45:16PM -0500, Philippe Blain wrote:
Show 15 quoted lines
> 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.
Junio C Hamano· Feb 26, 2021, 02:04 UTC · re: Seth House · lore

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

Seth House <seth@eseth.com> writes:
Show 22 quoted lines
> 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.
I'd rather see it as a completely separate patch.
Seth House· Feb 26, 2021, 23:35 UTC · re: Junio C Hamano · lore

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

On Thu, Feb 25, 2021 at 06:04:53PM -0800, Junio C Hamano wrote:
> Seth House <seth@eseth.com> writes:
> > 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?

Junio C Hamano· Feb 27, 2021, 01:52 UTC · re: Seth House · lore

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

Seth House <seth@eseth.com> writes:
Show 10 quoted lines
> On Thu, Feb 25, 2021 at 06:04:53PM -0800, Junio C Hamano wrote:
>> Seth House <seth@eseth.com> writes:
>> > 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.
Seth House· Feb 27, 2021, 02:17 UTC · re: Junio C Hamano · lore

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

On Fri, Feb 26, 2021 at 05:52:22PM -0800, Junio C Hamano wrote:
> 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.

← back to recent threads