Skip to contentSkip to conversation

mergetool: support absolute paths to tools by git config merge.<tool>path

PATCH In review Steffen Prohaska 5 participants 15 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mergetool: support absolute paths to tools by git config merge.<tool>path

This commit adds a mechanism to provide absolute paths to the commands called by 'git mergetool'. A path can be specified in the configuation variable merge.<toolname>path.

This mechanism is especially useful on Windows, where external programs are unlikely to be in the path.

---
 Documentation/git-mergetool.txt |    5 ++
 git-mergetool.sh                |   81 ++++++++++++++++++++++-----------------
 2 files changed, 51 insertions(+), 35 deletions(-)
Documentation/git-mergetool.txt +5 -0
index 6c32c6d..6b97aaa 100644
@@ -31,6 +31,11 @@ If a merge resolution program is not specified, 'git mergetool'
 will use the configuration variable merge.tool.  If the
 configuration variable merge.tool is not set, 'git mergetool'
 will pick a suitable default.
++
+You can explicitly provide a full path to the tool by setting the
+configuration variable merge.<tool>path. For example, you
+can configure the absolute path to kdiff3 by setting merge.kdiff3path.
+Otherise, 'git mergetool' assumes the tool is available in PATH.
 
 Author
 ------
git-mergetool.sh +46 -35

150 lines not on this page · raw message

Signature · 1 line
1.5.3.3.127.g40d17
#1 lore raw

PATCH 1/1 mergetool: add support for ECMerge

Add support for ECMerge available from
http://www.elliecomputing.com/Products/merge_overview.asp

---
 Documentation/git-mergetool.txt |    2 +-
 git-mergetool.sh                |   12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
Documentation/git-mergetool.txt +1 -1
index 6b97aaa..ece7718 100644
@@ -25,7 +25,7 @@ OPTIONS
 -t or --tool=<tool>::
 	Use the merge resolution program specified by <tool>.
 	Valid merge tools are:
-	kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, and opendiff
+	kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff
 +
 If a merge resolution program is not specified, 'git mergetool'
 will use the configuration variable merge.tool.  If the
git-mergetool.sh +11 -1
index 7f6c16f..39f6595 100755
@@ -250,6 +250,16 @@ merge_file () {
 	    check_unchanged
 	    save_backup
 	    ;;
+	ecmerge)
+	    touch "$BACKUP"
+	    if base_present; then
+		"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --mode=merge3 --to="$path"
+	    else
+		"$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path"
+	    fi
+	    check_unchanged
+	    save_backup
+	    ;;
 	emerge)
 	    if base_present ; then
 		"$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$path")"
@@ -299,7 +309,7 @@ done
 
 valid_tool() {
 	case "$1" in
-		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff)
+		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
 			;; # happy
 		*)
 			return 1
Signature · 1 line
1.5.3.3.127.g40d17
#2 lore raw

Re: [PATCH] mergetool: add support for ECMerge

Quoted 2 lines · Steffen Prohaska

Add support for ECMerge available from
http://www.elliecomputing.com/Products/merge_overview.asp

Hmm. A propietary merge tool. It's not that much code, so I guess....

I note though that it claims on the web page that they are integrated with "most famous SCM's", but they don't include git. If we add this support, are they going to change their web page? :-)

Also, ECmerge is supported on Linux, Solaris, MacOS X, and Windows. Which platforms have you tested on? My guess is that if it works on Linux, it'll probably work on Solaris and MacOS, but is it a fair guess you haven't tested under Windows? Not that most Windows systems are going to be able to use git-mergetool since it's a bash script, unless they are using Cygwin or some such.

- Ted

#3 lore raw

Re: [PATCH] mergetool: add support for ECMerge

Quoted 9 lines · Theodore Tso
Quoted 2 lines · Steffen Prohaska

Add support for ECMerge available from
http://www.elliecomputing.com/Products/merge_overview.asp

Hmm. A propietary merge tool. It's not that much code, so I guess....

I note though that it claims on the web page that they are integrated with "most famous SCM's", but they don't include git. If we add this support, are they going to change their web page? :-)

You may even apply for a free (as beer) license if you contribute to open source projects:

http://www.elliecomputing.com/Community/opensource.asp

I didn't try this, so I can't say how this works in practice.

Quoted 2 lines

Also, ECmerge is supported on Linux, Solaris, MacOS X, and Windows. Which platforms have you tested on?

Windows. Haven't tested Unix systems yet.

Quoted 5 lines

My guess is that if it works on
Linux, it'll probably work on Solaris and MacOS, but is it a fair guess you haven't tested under Windows? Not that most Windows systems are going to be able to use git-mergetool since it's a bash script, unless they are using Cygwin or some such.

I work on the msysgit project and I'd like to have mergetool available before I advertise git on Windows. It makes merging so much easier ;)

Steffen

#4 lore raw

Re: [PATCH] mergetool: add support for ECMerge

Hi,

Quoted 2 lines · Steffen Prohaska

I work on the msysgit project and I'd like to have mergetool available before I advertise git on Windows. It makes merging so much easier ;)

I would _hate_ to rely on a closed source program (in addition to Windows itself) in msysGit.

And it seems that you cannot even get ECMerge for free in general.

What does TortoiseCVS use?

Ciao,
Dscho

#5 lore raw

Re: [PATCH] mergetool: add support for ECMerge

Quoted 1 line · Johannes Schindelin

What does TortoiseCVS use?

They don't actually include it in the package, but they recommend WinMerge http://winmerge.org/, which is free (GPL).

Signature · 1 line
Alan Hadsell
#6 lore raw

Re: [PATCH] mergetool: add support for ECMerge

Quoted 6 lines · Alan Hadsell
Quoted 1 line · Johannes Schindelin

What does TortoiseCVS use?

They don't actually include it in the package, but they recommend WinMerge http://winmerge.org/, which is free (GPL).

WinMerge doesn't support 3-way merges. At least I cannot find any indication for 3-way in the manual [1] and the comparison at [2] also tells that WinMerge doesn't support 3-way.

Steffen

[1] http://winmerge.org/2.6/manual/CompareFiles.html
[2] http://en.wikipedia.org/wiki/Comparison_of_file_comparison_tools

#7 lore raw

Re: [PATCH] mergetool: add support for ECMerge

Quoted 5 lines · Steffen Prohaska

WinMerge doesn't support 3-way merges. At least I cannot find any indication for 3-way in the manual [1] and the comparison at [2] also tells that WinMerge doesn't support 3-way.

From their FAQ:

Does WinMerge support merging three files? Sometimes it is called 3-way merge, where one file is ancestor. This would be useful for version control!

Unfortunately not. We acknowledge it would be good feature but have no plans to implement it in near future. This can be somewhat worked around by using two WinMerge instances. (One developer has begun preliminary work on this feature, but it is not yet available, even in experimental releases.)

#8 lore raw

Re: [PATCH] mergetool: add support for ECMerge

In reply to Johannes Schindelin
Quoted 7 lines · Johannes Schindelin
Quoted 2 lines · Steffen Prohaska

I work on the msysgit project and I'd like to have mergetool available before I advertise git on Windows. It makes merging so much easier ;)

I would _hate_ to rely on a closed source program (in addition to Windows itself) in msysGit.

It's only an option. You can also choose kdiff3 if you like, or vimdiff or emacs merge. But personally, I prefer ECMerge because is seems to support a faster and safer workflow (at least for me).

Before submitted this patch I thought about a general mechanism to easily specify any tool that supports command line argument. But just adding them tool by tool as needed looks easier to me, and hopefully to the user. We can include the correct command line in git-mergetool and only require the location of the program from the user.

Quoted 1 line

And it seems that you cannot even get ECMerge for free in general.

True. But does it matter? I can't get Windows for free and git runs on it.

Quoted 1 line

What does TortoiseCVS use?

Don't know.

Steffen

#9 lore raw
In reply to Steffen Prohaska
Quoted 3 lines · Steffen Prohaska

This commit adds a mechanism to provide absolute paths to the commands called by 'git mergetool'. A path can be specified in the configuation variable merge.<toolname>path.

This patch doesn't work the config file doesn't specify an explicit
mergetool via merge.tool. The reason for that is this loop:

for i in $merge_tool_candidates; do
if test $i = emerge ; then
cmd=emacs
else
cmd=$i
fi
if type $cmd > /dev/null 2>&1; then
merge_tool=$i
break
fi
done

is only checking to see if $cmd is in the path; it's not looking up the merge.<toolname>path variable in this loop.

I guess the other question is whether we would be better off simply telling the user to specify an absolute pathname in merge.tool, and then having git-mergetool strip off the directory path via basename, and then on window systems, stripping off the .EXE or .COM suffix, and then downcasing the name so that something like "C:\Program Files\ECMerge\ECMerge.exe" gets translated to "ecmerge". Would I be right in guessing that the reason why you used merge.<toolname>path approach was to avoid this messy headache?

- Ted

#10 lore raw
Quoted 2 lines · Theodore Tso

This patch doesn't work the config file doesn't specify an explicit
mergetool via merge.tool. The reason for that is this loop:

Err, let me try that again. "This patch doesn't work IF the config file doesn't specify an explicit > mergetool via merge.tool."

Sorry about the missing conjuction; the sentence doesn't make much sense without it...

- Ted

#11 lore raw
In reply to Theodore Tso
Quoted 20 lines · Theodore Tso
Quoted 3 lines · Steffen Prohaska

This commit adds a mechanism to provide absolute paths to the commands called by 'git mergetool'. A path can be specified in the configuation variable merge.<toolname>path.

This patch doesn't work if the config file doesn't specify an explicit
mergetool via merge.tool. The reason for that is this loop:

for i in $merge_tool_candidates; do
if test $i = emerge ; then
cmd=emacs
else
cmd=$i
fi
if type $cmd > /dev/null 2>&1; then
merge_tool=$i
break
fi
done

Quoted 2 lines

is only checking to see if $cmd is in the path; it's not looking up the merge.<toolname>path variable in this loop.

I didn't change the automatic detection. It should work as before. That is it continues to assume that merge tools are in PATH.

Is you expectation that git-mergetool should also consider the absolute paths provided in merge.<toolname>path?

When I wrote the patch I had in mind that people will set the merge.tool explicitly if they provide an absolute path. Automatic detection would only be used if nothing is configured. In this case a tool must be in PATH or would not be found.

Quoted 8 lines

I guess the other question is whether we would be better off simply telling the user to specify an absolute pathname in merge.tool, and then having git-mergetool strip off the directory path via basename, and then on window systems, stripping off the .EXE or .COM suffix, and then downcasing the name so that something like "C:\Program Files\ECMerge\ECMerge.exe" gets translated to "ecmerge". Would I be right in guessing that the reason why you used merge.<toolname>path approach was to avoid this messy headache?

Yes. The program to start ECMerge on Windows is called 'guimerge.exe'. Hard to derive a sensible short name from this.

So I don't think that an automatic translation is an option. I prefer to provide the absolute paths.

Absolute paths have another advantage. You can set several of them and choose a tool on the command line. Maybe you have several tools you want to try. Or you hacking with someone else who preferes a different tool. Or you just want to give a demo. I see merge.<toolname>path more as a database associating absolute paths with the shortnames.

My mental model is as follows:
1) merge.tool selects the mechanism needed to call the tool, that is command line arguments, how merge result is passed, ...
2) merge.<toolname>path provides additional information how to locate the selected tool in the filesystem.

The two points are somewhat orthogonal. I'd not fuse them into one.

Steffen

#12 lore raw
In reply to Steffen Prohaska
Quoted 3 lines · Steffen Prohaska

This commit adds a mechanism to provide absolute paths to the commands called by 'git mergetool'. A path can be specified in the configuation variable merge.<toolname>path.

Why not merge.<toolname>.path?
This would it make easy to introduce new variables of the form merge.<toolname>.<var> later if needed. I also think it is more consistent with names of existing configuration variables. (think branch.<name>.<var> or remote.<name>.<var>)

Gruesse,

Signature · 2 lines
Frank Lichtenheld <[email protected]>
www: http://www.djpig.de/
#13 lore raw
Quoted 11 lines · Frank Lichtenheld
Quoted 3 lines · Steffen Prohaska

This commit adds a mechanism to provide absolute paths to the commands called by 'git mergetool'. A path can be specified in the configuation variable merge.<toolname>path.

Why not merge.<toolname>.path?

This would it make easy to introduce new variables of the form merge.<toolname>.<var> later if needed. I also think it is more consistent with names of existing configuration variables. (think branch.<name>.<var> or remote.<name>.<var>)

Looks more beautiful on the command line but a bit more complex in the config file. But I like the idea.

Maybe mergetool.<tool>.path is even a better choice? It clearly indicate the relationship with mergetool. We could explain:

'The variable merge.tool = <tool> refers to a tool that can be further specified in mergetool.<tool>.path.'

Steffen

#14 lore raw
In reply to Steffen Prohaska

Hi,

Quoted 3 lines · Steffen Prohaska

This commit adds a mechanism to provide absolute paths to the commands called by 'git mergetool'. A path can be specified in the configuation variable merge.<toolname>path.

Would it not be more in line with all other config variables if it was written merge.<toolname>.path? (Indeed, I thought your subject line contained a typo when I read it first.)

Ciao,
Dscho