Skip to contentSkip to conversation

Adding Beyond Compare as a merge tool, was: Re: What's cooking in git.git (Feb 2011, #05; Wed, 23)

PATCH In review Sebastian Schuberth 3 participants 8 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

cover Adding Beyond Compare as a merge tool, was: Re: What's cooking in git.git (Feb 2011, #05; Wed, 23)

This is the follow-up to

http://marc.info/?l=git&m=129871641232007&w=2

and an alternative to the proposed

cp/mergetool-beyondcompare

Sebastian Schuberth (3):
mergetool--lib: Sort tools alphabetically for easier lookup
mergetool--lib: Add Beyond Compare 3 as a tool
mergetool--lib: Add the proper executable name for ECMerge

 Documentation/git-difftool.txt         |    4 +-
 Documentation/git-mergetool.txt        |    4 +-
 Documentation/merge-config.txt         |    8 +-
 contrib/completion/git-completion.bash |    2 +-
 git-gui/lib/mergetool.tcl              |  101 +++++++------
 git-mergetool--lib.sh                  |  250 
+++++++++++++++++---------------
 6 files changed, 198 insertions(+), 171 deletions(-)
Signature · 1 line
1.7.3.2.msysgit.6.dirty
#1 lore raw

PATCH 1/3 mergetool--lib: Sort tools alphabetically for easier lookup

---
 Documentation/git-difftool.txt  |    4 +-
 Documentation/git-mergetool.txt |    4 +-
 Documentation/merge-config.txt  |    8 +-
 git-gui/lib/mergetool.tcl       |   94 ++++++++--------
 git-mergetool--lib.sh           |  245 +++++++++++++++++++--------------------
 5 files changed, 177 insertions(+), 178 deletions(-)
Documentation/git-difftool.txt +2 -2
index db87f1d..4c8825d 100644
@@ -31,8 +31,8 @@ OPTIONS
 --tool=<tool>::
 	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.
+	araxis, diffuse, emerge, ecmerge, gvimdiff, kdiff3,
+	kompare, meld, opendiff, p4merge, tkdiff, vimdiff and xxdiff.
 +
 If a diff tool is not specified, 'git difftool'
 will use the configuration variable `diff.tool`.  If the
Documentation/git-mergetool.txt +2 -2
index 1f75a84..4987245 100644
@@ -26,8 +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,
-	diffuse, tortoisemerge, opendiff, p4merge and araxis.
+	araxis, diffuse, ecmerge, emerge, gvimdiff, kdiff3,
+	meld, opendiff, p4merge, tkdiff, tortoisemerge, vimdiff and xxdiff.
 +
 If a merge resolution program is not specified, 'git mergetool'
 will use the configuration variable `merge.tool`.  If the
Documentation/merge-config.txt +4 -4
index 1e5c22c..90587db 100644
@@ -33,10 +33,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",
-	"diffuse", "ecmerge", "tortoisemerge", "p4merge", "araxis" and
-	"opendiff".  Any other value is treated is custom merge tool
+	linkgit:git-mergetool[1].  Valid built-in values are: "araxis",
+	"diffuse", "ecmerge", "emerge", "gvimdiff", "kdiff3", "meld",
+	"opendiff", "p4merge", "tkdiff", "tortoisemerge", "vimdiff"
+	and "xxdiff".  Any other value is treated is custom merge tool
 	and there must be a corresponding mergetool.<tool>.cmd option.
 
 merge.verbosity::
git-gui/lib/mergetool.tcl +47 -47

137 lines not on this page · raw message

git-mergetool--lib.sh +122 -123

339 lines not on this page · raw message

Signature · 1 line
1.7.3.2.msysgit.6.dirty
#2 lore raw

PATCH 2/3 mergetool--lib: Add Beyond Compare 3 as a tool

In reply to Sebastian Schuberth
---
 Documentation/git-difftool.txt         |    2 +-
 Documentation/git-mergetool.txt        |    2 +-
 Documentation/merge-config.txt         |    2 +-
 contrib/completion/git-completion.bash |    2 +-
 git-gui/lib/mergetool.tcl              |    7 +++++++
 git-mergetool--lib.sh                  |   22 ++++++++++++++++++++--
 6 files changed, 31 insertions(+), 6 deletions(-)
Documentation/git-difftool.txt +1 -1
index 4c8825d..f087eff 100644
@@ -31,7 +31,7 @@ OPTIONS
 --tool=<tool>::
 	Use the diff tool specified by <tool>.
 	Valid merge tools are:
-	araxis, diffuse, emerge, ecmerge, gvimdiff, kdiff3,
+	araxis, bc3, diffuse, emerge, ecmerge, gvimdiff, kdiff3,
 	kompare, meld, opendiff, p4merge, tkdiff, vimdiff and xxdiff.
 +
 If a diff tool is not specified, 'git difftool'
Documentation/git-mergetool.txt +1 -1
index 4987245..740b3f1 100644
@@ -26,7 +26,7 @@ OPTIONS
 --tool=<tool>::
 	Use the merge resolution program specified by <tool>.
 	Valid merge tools are:
-	araxis, diffuse, ecmerge, emerge, gvimdiff, kdiff3,
+	araxis, bc3, diffuse, ecmerge, emerge, gvimdiff, kdiff3,
 	meld, opendiff, p4merge, tkdiff, tortoisemerge, vimdiff and xxdiff.
 +
 If a merge resolution program is not specified, 'git mergetool'
Documentation/merge-config.txt +1 -1
index 90587db..33bf74c 100644
@@ -34,7 +34,7 @@ merge.stat::
 merge.tool::
 	Controls which merge resolution program is used by
 	linkgit:git-mergetool[1].  Valid built-in values are: "araxis",
-	"diffuse", "ecmerge", "emerge", "gvimdiff", "kdiff3", "meld",
+	"bc3", "diffuse", "ecmerge", "emerge", "gvimdiff", "kdiff3", "meld",
 	"opendiff", "p4merge", "tkdiff", "tortoisemerge", "vimdiff"
 	and "xxdiff".  Any other value is treated is custom merge tool
 	and there must be a corresponding mergetool.<tool>.cmd option.
contrib/completion/git-completion.bash +1 -1
index 893b771..058c2a9 100755
@@ -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 bc3
 "
 
 _git_difftool ()
git-gui/lib/mergetool.tcl +7 -0
index 249e0cf..3c8e73b 100644
@@ -187,6 +187,13 @@ proc merge_resolve_tool2 {} {
 				 "$LOCAL" "$REMOTE" "$MERGED"]
 		}
 	}
+	bc3 {
+		if {$base_stage ne {}} {
+			set cmdline [list "$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" -mergeoutput="$MERGED"]
+		} else {
+			set cmdline [list "$merge_tool_path" "$LOCAL" "$REMOTE" -mergeoutput="$MERGED"]
+		}
+	}
 	ecmerge {
 		if {$base_stage ne {}} {
 			set cmdline [list "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --default --mode=merge3 --to="$MERGED"]
git-mergetool--lib.sh +20 -2
index 9fb82e5..3ac6231 100644
@@ -13,6 +13,9 @@ translate_merge_tool_path () {
 	araxis)
 		echo compare
 		;;
+	bc3)
+		echo BCompare
+		;;
 	emerge)
 		echo emacs
 		;;
@@ -46,7 +49,7 @@ check_unchanged () {
 
 valid_tool () {
 	case "$1" in
-	araxis | diffuse | ecmerge | emerge | gvimdiff | gvimdiff2 | \
+	araxis | bc3 | diffuse | ecmerge | emerge | gvimdiff | gvimdiff2 | \
 	kdiff3 | meld | opendiff | p4merge | tkdiff | vimdiff | vimdiff2 | xxdiff)
 		;; # happy
 	kompare)
@@ -106,6 +109,21 @@ run_merge_tool () {
 				>/dev/null 2>&1
 		fi
 		;;
+	bc3)
+		if merge_mode; then
+			touch "$BACKUP"
+			if $base_present; then
+				"$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" \
+					-mergeoutput="$MERGED"
+			else
+				"$merge_tool_path" "$LOCAL" "$REMOTE" \
+					-mergeoutput="$MERGED"
+			fi
+			check_unchanged
+		else
+			"$merge_tool_path" "$LOCAL" "$REMOTE"
+		fi
+		;;
 	diffuse)
 		if merge_mode; then
 			touch "$BACKUP"
@@ -342,7 +360,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 bc3"
 	fi
 	case "${VISUAL:-$EDITOR}" in
 	*vim*)
Signature · 1 line
1.7.3.2.msysgit.6.dirty
#3 lore raw

PATCH 3/3 mergetool--lib: Add the proper executable name for ECMerge

In reply to Sebastian Schuberth
---
 git-mergetool--lib.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
git-mergetool--lib.sh +3 -0
index 3ac6231..95da00b 100644
@@ -16,6 +16,9 @@ translate_merge_tool_path () {
 	bc3)
 		echo BCompare
 		;;
+	ecmerge)
+		echo guimerge
+		;;
 	emerge)
 		echo emacs
 		;;
Signature · 1 line
1.7.3.2.msysgit.6.dirty
#4 lore raw

Re: [PATCH 3/3] mergetool--lib: Add the proper executable name for ECMerge

Quoted 10 lines · Sebastian Schuberth
---
 git-mergetool--lib.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
git-mergetool--lib.sh +0 -0
index 3ac6231..95da00b 100644

git-mergetool--lib.sh translate_merge_tool_path () { · line 24

Quoted 9 lines
git-mergetool--lib.sh +3 -0
@@ -16,6 +16,9 @@ translate_merge_tool_path () {
 	bc3)
 		echo BCompare
 		;;
+	ecmerge)
+		echo guimerge
+		;;
 	emerge)
 		echo emacs
 		;;

I think this is another case of linux/windows versions of the application having different executable names.

chrisp@laptop:~> tar -tf Download/ecmerge-2.3.123.linux.x86.tbz /usr/local/bin/ecmerge /opt/elliecomputing/ecmerge/guimerge /opt/elliecomputing/ecmerge/guimerge.exe

#5 lore raw

Re: [PATCH 3/3] mergetool--lib: Add the proper executable name for ECMerge

Quoted 7 lines · Chris Packham
Quoted 6 lines

+     ecmerge)
+             echo guimerge
+             ;;
      emerge)
              echo emacs
              ;;

Quoted 7 lines

I think this is another case of linux/windows versions of the application having different executable names.

chrisp@laptop:~> tar -tf Download/ecmerge-2.3.123.linux.x86.tbz /usr/local/bin/ecmerge /opt/elliecomputing/ecmerge/guimerge /opt/elliecomputing/ecmerge/guimerge.exe

Indeed, well except that Linux has both "ecmerge" and "guimerge", whereas Windows only has "guimerge", which is why I went with the latter. Giving it a second thought, my patch is a little inconvenient for Linux users, as it will stop making ecmerge work out of the box (without first setting mergetool.ecmerge.path), whereas Windows users need to set mergetool.ecmerge.path anyway.

I've also contacted the makers of ECMerge and asked them to unify the naming across platforms. Maybe we should just drop this patch until they did.

Chris, what do you think?

Signature · 1 line
Sebastian Schuberth
#6 lore raw

Re: [PATCH 3/3] mergetool--lib: Add the proper executable name for ECMerge

Quoted 24 lines · Sebastian Schuberth
Quoted 7 lines · Chris Packham

git-mergetool--lib.sh translate_merge_tool_path () { · line 24

Quoted 6 lines
git-mergetool--lib.sh +3 -0
+     ecmerge)
+             echo guimerge
+             ;;
      emerge)
              echo emacs
              ;;
Quoted 7 lines

I think this is another case of linux/windows versions of the application having different executable names.

chrisp@laptop:~> tar -tf Download/ecmerge-2.3.123.linux.x86.tbz /usr/local/bin/ecmerge /opt/elliecomputing/ecmerge/guimerge /opt/elliecomputing/ecmerge/guimerge.exe

Indeed, well except that Linux has both "ecmerge" and "guimerge", whereas Windows only has "guimerge", which is why I went with the latter. Giving it a second thought, my patch is a little inconvenient for Linux users, as it will stop making ecmerge work out of the box (without first setting mergetool.ecmerge.path), whereas Windows users need to set mergetool.ecmerge.path anyway.

Quoted 5 lines

I've also contacted the makers of ECMerge and asked them to unify the naming across platforms. Maybe we should just drop this patch until they did.

Chris, what do you think?

If the ecmerge makers can get 'ecmerge' to be a valid command on windows then that'd be the best solution for now.

I have a different idea for handling this going forward (maybe for v1.8.0). One benefit of having built-in knowledge of a mergetool, as opposed to using config variables, is git knows when to do a 2-way merge vs a 3-way merge. So instead of having a single mergetool.cmd maybe we need mergetool.cmd2way and mergetool.cmd3way, all of the existing supported mergetools could then be expressed as a set of config variables (maybe installed in system or global configs by the git installation process).

I'll try to write that up as a proper v1.8.0 proposal when I get a chance.

#7 lore raw
In reply to Sebastian Schuberth
Quoted 5 lines · Sebastian Schuberth

Sebastian Schuberth (3):
mergetool--lib: Sort tools alphabetically for easier lookup
mergetool--lib: Add Beyond Compare 3 as a tool
mergetool--lib: Add the proper executable name for ECMerge

Quoted 8 lines
 Documentation/git-difftool.txt         |    4 +-
 Documentation/git-mergetool.txt        |    4 +-
 Documentation/merge-config.txt         |    8 +-
 contrib/completion/git-completion.bash |    2 +-
 git-gui/lib/mergetool.tcl              |  101 +++++++------
 git-mergetool--lib.sh                  |  250
+++++++++++++++++---------------
 6 files changed, 198 insertions(+), 171 deletions(-)

Ohh, somebody line-wrapped your message.

I've dropped git-gui/ bits from the series, and queued the remainder as ss/mergetool-lib branch. I also forked git-gui and queued the git-gui/ bits there to create ss/git-gui-mergetool branch.

When the ss/mergetool-lib branch gets ready to be merged to 'next', I'll ask Pat to keep an eye on the ss/git-gui-mergetool branch and we will coordinate the merge of these two topics to our respective 'master' branches to make sure that the git-core side graduates first and followed by git-gui side.

Thanks.