Using GIT and p4merge on Mac OSX

I found an article on setting up my .gitconfig file to launch p4merge as my custom merge tool:
Using p4merge as a custom Git merge tool on Mac OS X

The problem was I would get the following errors when there were spaces in my merge file paths. For a path like /path/to the/file.rb I would get something like:


Incorrect parameters:
Too many files: You may enter a maximum of 4 files.
'/path/to' is (or points to) an invalid file.
'the/file.rb' is (or points to) an invalid file.
...

Here’s the easy solution that fixed this problem on my system:


[merge]
    keepBackup = false
	tool = custom
[mergetool "custom"]
	cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\""
	keepTemporaries = false
	trustExitCode = false
	keepBackup = false

Notice the extra (escaped) quote marks around the parameters. This could also be handled with a shell script, but I didn’t want an extra moving part to make the magic happen. Life is already complicated…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>