# [PATCH] Add diffuse as merge and diff tool

3 messages from 2009-03-28 to 2009-03-30. Participants: Sebastian Pipping, David Aguilar.
Thread: https://gitlist.dev/t/18605

## Sebastian Pipping, 2009-03-28 22:25

Subject: [PATCH] Add diffuse as merge and diff tool
Message-ID: <49CEA3E2.9020805@hartwork.org>
URL: https://gitlist.dev/e/49CEA3E2.9020805%40hartwork.org

```



>From e54c153a67cef9b162eb51f4b7cefb65e59c3a13 Mon Sep 17 00:00:00 2001
From: Sebastian Pipping <sebastian@pipping.org>
Date: Thu, 26 Mar 2009 20:42:31 +0100
Subject: [PATCH] Add diffuse as merge and diff tool

---
 Documentation/git-mergetool.txt        |    3 ++-
 Documentation/merge-config.txt         |    7 ++++---
 contrib/completion/git-completion.bash |    3 ++-
 contrib/difftool/git-difftool-helper   |   12 ++++++++----
 contrib/difftool/git-difftool.txt      |    4 ++--
 git-gui/lib/mergetool.tcl              |    7 +++++++
 git-mergetool.sh                       |   15 ++++++++++++---
 7 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index 5d3c632..c3a8092 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -26,7 +26,8 @@ OPTIONS
 --tool=<tool>::
 	Use the merge resolution program specified by <tool>.
 	Valid merge tools are:
-	kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff
+	kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge,
+	diffuse and opendiff
 +
 If a merge resolution program is not specified, 'git-mergetool'
 will use the configuration variable `merge.tool`.  If the
diff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt
index 1ff08ff..ef07cf2 100644
--- a/Documentation/merge-config.txt
+++ b/Documentation/merge-config.txt
@@ -22,9 +22,10 @@ merge.stat::
 merge.tool::
 	Controls which merge resolution program is used by
 	linkgit:git-mergetool[1].  Valid built-in values are: "kdiff3",
-	"tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
-	"opendiff".  Any other value is treated is custom merge tool
-	and there must be a corresponding mergetool.<tool>.cmd option.
+	"tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff",
+	"diffuse" and "opendiff".  Any other value is treated is custom
+	merge tool and there must be a corresponding mergetool.<tool>.cmd
+	option.
 
 merge.verbosity::
 	Controls the amount of output shown by the recursive merge
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1c6b0e2..2e7a9d7 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1173,7 +1173,8 @@ _git_mergetool ()
 	--tool=*)
 		__gitcomp "
 			kdiff3 tkdiff meld xxdiff emerge
-			vimdiff gvimdiff ecmerge opendiff
+			vimdiff gvimdiff ecmerge diffuse
+			opendiff
 			" "" "${cur##--tool=}"
 		return
 		;;
diff --git a/contrib/difftool/git-difftool-helper b/contrib/difftool/git-difftool-helper
index 9c0a134..ea44e4e 100755
--- a/contrib/difftool/git-difftool-helper
+++ b/contrib/difftool/git-difftool-helper
@@ -1,6 +1,6 @@
 #!/bin/sh
 # git-difftool-helper is a GIT_EXTERNAL_DIFF-compatible diff tool launcher.
-# It supports kdiff3, kompare, tkdiff, xxdiff, meld, opendiff,
+# It supports kdiff3, kompare, tkdiff, xxdiff, meld, diffuse, opendiff,
 # emerge, ecmerge, vimdiff, gvimdiff, and custom user-configurable tools.
 # This script is typically launched by using the 'git difftool'
 # convenience command.
@@ -103,6 +103,10 @@ launch_merge_tool () {
 			"$LOCAL" "$REMOTE"
 		;;
 
+	diffuse)
+		"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
+		;;
+
 	opendiff)
 		"$merge_tool_path" "$LOCAL" "$REMOTE" \
 			-merge "$MERGED" | cat
@@ -140,7 +144,7 @@ valid_custom_tool() {
 # Built-in merge tools are always valid.
 valid_tool() {
 	case "$1" in
-	kdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
+	kdiff3 | kompare | tkdiff | xxdiff | meld | diffuse | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
 		;; # happy
 	*)
 		if ! valid_custom_tool "$1"
@@ -194,9 +198,9 @@ if test -z "$merge_tool"; then
 	if test -n "$DISPLAY"; then
 		# If gnome then prefer meld, otherwise, prefer kdiff3 or kompare
 		if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
-			merge_tool_candidates="meld kdiff3 kompare tkdiff xxdiff gvimdiff"
+			merge_tool_candidates="meld kdiff3 kompare tkdiff xxdiff gvimdiff diffuse"
 		else
-			merge_tool_candidates="kdiff3 kompare tkdiff xxdiff meld gvimdiff"
+			merge_tool_candidates="kdiff3 kompare tkdiff xxdiff meld gvimdiff diffuse"
 		fi
 	fi
 	if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
diff --git a/contrib/difftool/git-difftool.txt b/contrib/difftool/git-difftool.txt
index 2b7bc03..6419d37 100644
--- a/contrib/difftool/git-difftool.txt
+++ b/contrib/difftool/git-difftool.txt
@@ -28,8 +28,8 @@ OPTIONS
 --tool=<tool>::
 	Use the merge resolution program specified by <tool>.
 	Valid merge tools are:
-	kdiff3, kompare, tkdiff, meld, xxdiff, emerge,
-	vimdiff, gvimdiff, ecmerge, and opendiff
+	kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff,
+	ecmerge, diffuse and opendiff
 +
 If a merge resolution program is not specified, 'git-difftool'
 will use the configuration variable `diff.tool`.  If the
diff --git a/git-gui/lib/mergetool.tcl b/git-gui/lib/mergetool.tcl
index eb2b4b5..658c021 100644
--- a/git-gui/lib/mergetool.tcl
+++ b/git-gui/lib/mergetool.tcl
@@ -219,6 +219,13 @@ proc merge_resolve_tool2 {} {
 			set cmdline [list "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$MERGED"]
 		}
 	}
+	diffuse {
+		if {$base_stage ne {}} {
+			set cmdline [list "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE" "$BASE" ]
+		} else {
+			set cmdline [list "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE" ]
+		}
+	}
 	ecmerge {
 		if {$base_stage ne {}} {
 			set cmdline [list "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --default --mode=merge3 --to="$MERGED"]
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 87fa88a..2c96da1 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -239,6 +239,15 @@ merge_file () {
 	    fi
 	    check_unchanged
 	    ;;
+	diffuse)
+	    touch "$BACKUP"
+	    if base_present; then
+		"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE" "$BASE" | cat
+	    else
+		"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE" | cat
+	    fi
+	    check_unchanged
+	    ;;
 	opendiff)
 	    touch "$BACKUP"
 	    if base_present; then
@@ -345,7 +354,7 @@ valid_custom_tool()
 
 valid_tool() {
 	case "$1" in
-		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
+		kdiff3 | tkdiff | xxdiff | meld | diffuse | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
 			;; # happy
 		*)
 			if ! valid_custom_tool "$1"; then
@@ -398,9 +407,9 @@ fi
 if test -z "$merge_tool" ; then
     if test -n "$DISPLAY"; then
         if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
-            merge_tool_candidates="meld kdiff3 tkdiff xxdiff gvimdiff"
+            merge_tool_candidates="meld kdiff3 tkdiff xxdiff gvimdiff diffuse"
         else
-            merge_tool_candidates="kdiff3 tkdiff xxdiff meld gvimdiff"
+            merge_tool_candidates="kdiff3 tkdiff xxdiff meld gvimdiff diffuse"
         fi
     fi
     if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
-- 
1.6.2.1-2808-gb0085a7


```

## David Aguilar, 2009-03-30 04:55

Subject: Re: [PATCH] Add diffuse as merge and diff tool
Message-ID: <20090330045522.GA8308@gmail.com>
URL: https://gitlist.dev/e/20090330045522.GA8308%40gmail.com
In-Reply-To: <49CEA3E2.9020805@hartwork.org>

```

Hi

On  0, Sebastian Pipping <webmaster@hartwork.org> wrote:
> 

> From e54c153a67cef9b162eb51f4b7cefb65e59c3a13 Mon Sep 17 00:00:00 2001
> From: Sebastian Pipping <sebastian@pipping.org>
> Date: Thu, 26 Mar 2009 20:42:31 +0100
> Subject: [PATCH] Add diffuse as merge and diff tool
> 
> ---
>  Documentation/git-mergetool.txt        |    3 ++-
>  Documentation/merge-config.txt         |    7 ++++---
>  contrib/completion/git-completion.bash |    3 ++-
>  contrib/difftool/git-difftool-helper   |   12 ++++++++----
>  contrib/difftool/git-difftool.txt      |    4 ++--
>  git-gui/lib/mergetool.tcl              |    7 +++++++
>  git-mergetool.sh                       |   15 ++++++++++++---
>  7 files changed, 37 insertions(+), 14 deletions(-)


Hey, thanks for the patch.
Ouch.. too many places with duplicated information, huh?

I'm in the middle of refactoring git-(diff|merge)tool so that
there is less duplication of code.

Junio also has a number of difftool-related patches in his
proposed-updates "pu" branch.

Sebastian, would you mind if I rebased your patch on top of my
work (once I send it out) so that it makes things easier on
our kind maintainer?  I have a big patch series coming down that
does away with the redundancies so I think it'd be best if we
transfered your changes on top of it.  Would you mind if I
rebased your patch and sent it out to the list?

It wouldn't be until much later tonight (or tomorrow) at the
earliest since I have some unpacking to take care of but if
that's cool with you just let me know.

You should see the refactoring patches from me shortly...



-- 
		David

```

## Sebastian Pipping, 2009-03-30 16:41

Subject: Re: [PATCH] Add diffuse as merge and diff tool
Message-ID: <49D0F63D.2050205@hartwork.org>
URL: https://gitlist.dev/e/49D0F63D.2050205%40hartwork.org
In-Reply-To: <20090330045522.GA8308@gmail.com>

```
David Aguilar wrote:
>>  Documentation/git-mergetool.txt        |    3 ++-
>>  Documentation/merge-config.txt         |    7 ++++---
>>  contrib/completion/git-completion.bash |    3 ++-
>>  contrib/difftool/git-difftool-helper   |   12 ++++++++----
>>  contrib/difftool/git-difftool.txt      |    4 ++--
>>  git-gui/lib/mergetool.tcl              |    7 +++++++
>>  git-mergetool.sh                       |   15 ++++++++++++---
>>  7 files changed, 37 insertions(+), 14 deletions(-)
> 
> 
> Hey, thanks for the patch.
> Ouch.. too many places with duplicated information, huh?

Yes.


> I'm in the middle of refactoring git-(diff|merge)tool so that
> there is less duplication of code.
> 
> Junio also has a number of difftool-related patches in his
> proposed-updates "pu" branch.
> 
> Sebastian, would you mind if I rebased your patch on top of my
> work (once I send it out) so that it makes things easier on
> our kind maintainer?  I have a big patch series coming down that
> does away with the redundancies so I think it'd be best if we
> transfered your changes on top of it.  Would you mind if I
> rebased your patch and sent it out to the list?
> 
> It wouldn't be until much later tonight (or tomorrow) at the
> earliest since I have some unpacking to take care of but if
> that's cool with you just let me know.
> 
> You should see the refactoring patches from me shortly...

My patch is your patch, do as you please.

Just take care to keep the order of the files passed
to Diffuse intact, especially with $MERGED second,
as Diffuse sets focus on the second document after startup.



Sebastian

```
