[PATCH] mergetool--lib: add support for beyond compare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add support for Beyond Compare as a diff/merge tool.

Signed-off-by: Chris Packham <judge.packham@xxxxxxxxx>
---
Beyond compare is a non-free file comparison tool for Linux and Windows. A
trial version is available here [1]. People at $dayjob had used beyond compare
v2.0 for Windows a while ago but we hadn't paid attention since the change to
Linux. We noticed the other day that with v3.0 a native Linux version was now
available.

I wasn't sure about whether git should have support for non-free external
tools.  Then I saw that support for Araxis had been added in b6f0621a, which
I've used as a guide for this patch.

The actual problem I was trying to solve was that if I configure an external
merge tool beyond compare gets confused when $BASE does not exist (I think this
might be a problem for other tools too). I could work around the problem with
the following messy config

[mergetool "bcompare"]
        cmd = test -e \"$BASE\" && bcompare \"$BASE\" \"$LOCAL\" \"$REMOTE\" -mergeoutput=\"$MERGED\" || bcompare \"$LOCAL\" \"$REMOTE\" -mergeoutput=\"$MERGED\"

I've tested this with the Linux version and it works well, it'd be nice to hear
from some windows folks. In particular I think the option flags might change to
use '/' instead of '-' 

[1] http://www.scootersoftware.com/download.php

 Documentation/git-difftool.txt         |    2 +-
 Documentation/git-mergetool.txt        |    2 +-
 Documentation/merge-config.txt         |    6 +++---
 contrib/completion/git-completion.bash |    2 +-
 git-mergetool--lib.sh                  |   18 ++++++++++++++++--
 5 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index db87f1d..35ec927 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -32,7 +32,7 @@ OPTIONS
 	Use the diff tool specified by <tool>.
 	Valid merge tools are:
 	kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff,
-	ecmerge, diffuse, opendiff, p4merge and araxis.
+	ecmerge, diffuse, opendiff, p4merge, araxis and bcompare.
 +
 If a diff tool is not specified, 'git difftool'
 will use the configuration variable `diff.tool`.  If the
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index 1f75a84..0239929 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -27,7 +27,7 @@ OPTIONS
 	Use the merge resolution program specified by <tool>.
 	Valid merge tools are:
 	kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge,
-	diffuse, tortoisemerge, opendiff, p4merge and araxis.
+	diffuse, tortoisemerge, opendiff, p4merge, araxis and bcompare.
 +
 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 1e5c22c..87c76e5 100644
--- a/Documentation/merge-config.txt
+++ b/Documentation/merge-config.txt
@@ -35,9 +35,9 @@ 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",
-	"diffuse", "ecmerge", "tortoisemerge", "p4merge", "araxis" and
-	"opendiff".  Any other value is treated is custom merge tool
-	and there must be a corresponding mergetool.<tool>.cmd option.
+	"diffuse", "ecmerge", "tortoisemerge", "p4merge", "araxis",
+	"opendiff" and "bcompare".  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 893b771..59ae12e 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1358,7 +1358,7 @@ _git_diff ()
 }
 
 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
-			tkdiff vimdiff gvimdiff xxdiff araxis p4merge
+			tkdiff vimdiff gvimdiff xxdiff araxis p4merge bcompare
 "
 
 _git_difftool ()
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 77d4aee..c77ac7f 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -48,7 +48,7 @@ valid_tool () {
 	case "$1" in
 	kdiff3 | tkdiff | xxdiff | meld | opendiff | \
 	vimdiff | gvimdiff | vimdiff2 | gvimdiff2 | \
-	emerge | ecmerge | diffuse | araxis | p4merge)
+	emerge | ecmerge | diffuse | araxis | p4merge | bcompare)
 		;; # happy
 	tortoisemerge)
 		if ! merge_mode; then
@@ -304,6 +304,20 @@ run_merge_tool () {
 				>/dev/null 2>&1
 		fi
 		;;
+	bcompare)
+		if merge_mode; then
+			if $base_present; then
+				"$merge_tool_path" \
+					"$BASE" "$LOCAL" "$REMOTE" -mergeoutput="$MERGED"
+			else
+				"$merge_tool_path" \
+					"$LOCAL" "$REMOTE" -mergeoutput="$MERGED"
+			fi
+			check_unchanged
+		else
+			"$merge_tool_path" "$LOCAL" "$REMOTE"
+		fi
+		;;
 	*)
 		merge_tool_cmd="$(get_merge_tool_cmd "$1")"
 		if test -z "$merge_tool_cmd"; then
@@ -343,7 +357,7 @@ guess_merge_tool () {
 		else
 			tools="opendiff kdiff3 tkdiff xxdiff meld $tools"
 		fi
-		tools="$tools gvimdiff diffuse ecmerge p4merge araxis"
+		tools="$tools gvimdiff diffuse ecmerge p4merge araxis bcompare"
 	fi
 	case "${VISUAL:-$EDITOR}" in
 	*vim*)
-- 
1.7.4.1.48.g5673d.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]