mergetool--lib: add support for p4merge
PATCH 1/1 mergetool--lib: add support for p4merge
Add native support for p4merge as a diff / merge tool. There are two oddities. First, launching p4merge on Mac OS X requires running a helper shim (which in turn is looked for in a couple common locations, as it's very unlikely to be in PATH). Second, p4merge seems to require its file arguments be absolute paths.
---
As requested by an Android developer at GitTogether09.
Only tested on Mac OS X 10.6.1. Feedback from anyone running p4merge on other OS's would be appreciated.
Documentation/git-difftool.txt | 2 +- Documentation/git-mergetool.txt | 2 +- git-mergetool--lib.sh | 44 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-)
Documentation/git-difftool.txt +1 -1
@@ -31,7 +31,7 @@ OPTIONS Use the diff tool specified by <tool>. Valid merge tools are: kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, - ecmerge, diffuse, opendiff and araxis. + ecmerge, diffuse, opendiff, p4merge and araxis. + If a diff tool is not specified, 'git-difftool' will use the configuration variable `diff.tool`. If the
Documentation/git-mergetool.txt +1 -1
@@ -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 and araxis. + diffuse, tortoisemerge, opendiff, p4merge and araxis. + If a merge resolution program is not specified, 'git-mergetool' will use the configuration variable `merge.tool`. If the
git-mergetool--lib.sh +43 -1
68 lines not on this page · raw message
Signature · 1 line
1.6.5.2.74.g610f9.dirty
Quoted 8 lines · Jay Soffian
Add native support for p4merge as a diff / merge tool. There are two oddities. First, launching p4merge on Mac OS X requires running a helper shim (which in turn is looked for in a couple common locations, as it's very unlikely to be in PATH). Second, p4merge seems to require its file arguments be absolute paths.
Signed-off-by Jay Soffian <[email protected]>---
Amusing. I didn't see Scott's patch.
But, in my testing, for things to work properly I needed to use launchp4merge per:
http://kb.perforce.com/AllPerforceApplications/StandAloneClients/P4merge/CommandLineP..rgeOnMacOsX
And I also found things didn't work properly unless I provided an absolute path.
(Aside, the "right" way to launch p4merge, at least on 10.6 would be:
/usr/bin/open -b com.perforce.p4merge -W -n --args <args to p4merge...>
This way OS X's launch services would find p4merge.app wherever it is on the user's system. But, I think some of these options to open are 10.6 specific and in practice looking in /Applications and $HOME/Applications I think is a sane enough default.)
j.
Quoted 11 lines · Jay Soffian
Quoted 8 lines · Jay Soffian
Add native support for p4merge as a diff / merge tool. There are two oddities. First, launching p4merge on Mac OS X requires running a helper shim (which in turn is looked for in a couple common locations, as it's very unlikely to be in PATH). Second, p4merge seems to require its file arguments be absolute paths.
Signed-off-by Jay Soffian <[email protected]>---
Amusing. I didn't see Scott's patch.
Apologies Jay!
It's late and I saw Scott listed in the CC: and guessed wrong ;)
Thanks for the patch again, man. Good stuff.
Quoted 18 lines
But, in my testing, for things to work properly I needed to use launchp4merge per:
http://kb.perforce.com/AllPerforceApplications/StandAloneClients/P4merge/CommandLineP..rgeOnMacOsX
And I also found things didn't work properly unless I provided an absolute path.
(Aside, the "right" way to launch p4merge, at least on 10.6 would be:
/usr/bin/open-b com.perforce.p4merge -W -n --args <args to p4merge...>This way OS X's launch services would find p4merge.app wherever it is on the user's system. But, I think some of these options to open are 10.6 specific and in practice looking in /Applications and $HOME/Applications I think is a sane enough default.)
j.
Signature · 1 line
David
Quoted 11 lines · Jay Soffian
But, in my testing, for things to work properly I needed to use launchp4merge per:
http://kb.perforce.com/AllPerforceApplications/StandAloneClients/P4merge/CommandLineP..rgeOnMacOsX
And I also found things didn't work properly unless I provided an absolute path.
(Aside, the "right" way to launch p4merge, at least on 10.6 would be:
/usr/bin/open-b com.perforce.p4merge -W -n --args <args to p4merge...>
:(
I tested on 10.5, so there's definitely some difference in behavior since difftool.p4merge.path is all that was needed here (with an absolute path as I mentioned).
Quoted 4 lines
This way OS X's launch services would find p4merge.app wherever it is on the user's system. But, I think some of these options to open are 10.6 specific and in practice looking in /Applications and $HOME/Applications I think is a sane enough default.)
We've stayed away from hard-coding any platform-specific paths in mergetool--lib in the past. It's a practicality thing -- trying to guess all of the possible installation locations is simply untenable.
Here's an old thread where we talked about this in the context of ecmerge:
http://thread.gmane.org/gmane.comp.version-control.git/118125/focus=118182
Let me know what you think.
Signature · 1 line
David
Quoted 3 lines · David Aguilar
I tested on 10.5, so there's definitely some difference in behavior since difftool.p4merge.path is all that was needed here (with an absolute path as I mentioned).
There are two issues here:
1) Is it necessary to use launchp4merge, or is calling p4merge directly okay:
Calling p4merge directly works, but the advantage of calling launchp4merge instead is that it works a little more elegantly:
- If p4merge is already running, using launchp4merge opens a new window inside the running instance, instead of launching p4merge anew.
- After performing the merge, it is sufficient to just close the merge window, as opposed to having to quit the p4merge application (which you have to do if you run p4merge directly).
2) Does p4merge/launchp4merge require absolute paths for its arguments.
I found that it does. So I wonder whether possibly you tested with difftool, which uses absolute arguments, as opposed to mergetool, which uses relative arguments. You'd only see the issue with mergetool.
Quoted 11 lines
We've stayed away from hard-coding any platform-specific paths in mergetool--lib in the past. It's a practicality thing -- trying to guess all of the possible installation locations is simply untenable.
Here's an old thread where we talked about this in the context of ecmerge:
http://thread.gmane.org/gmane.comp.version-control.git/118125/focus=118182
Let me know what you think.
Disagree with the conclusion of that thread. On Linux, PATH is very likely to have the merge/diff binary in it. On OS X, this is highly unlikely, but there are two very common/likely locations we can look, /Applications and $HOME/Applications.
j.
Quoted 3 lines · Jay Soffian
2) Does p4merge/launchp4merge require absolute paths for its arguments.
I found that it does.
I lie. Running p4merge directly works with relative paths. Launching p4merge via launchp4merge (or via open) requires absolute paths, which I guess makes sense.
I'd still lean toward using launchp4merge with absolute paths.
$0.02.
j.