diff mbox series

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

Message ID 20210214022840.849312-2-seth@eseth.com (mailing list archive)
State Accepted
Commit dbd4c6684ceb96d79e41b8ad9730abfaf83e165c
Headers show
Series mergetools/vimdiff: add vimdiff1 merge tool variant | expand

Commit Message

Seth House Feb. 14, 2021, 2:28 a.m. UTC
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(-)

Comments

Junio C Hamano Feb. 16, 2021, 6:38 p.m. UTC | #1
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.

> 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, 6:55 p.m. UTC | #2
On Tue, Feb 16, 2021 at 10:42 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> 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, 4:02 p.m. UTC | #3
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.
diff mbox series

Patch

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