git and Changes.app: take two, the right way to do it
Well, thanks to a pointer I found out that my git-chdiff script is a bit overblown. You see, a person can just use the built in functionality of git, namely setting the GIT_EXTERNAL_DIFF environment variable to point to something that can take the seven command line arguments git will pass on to whatever you’ve set as your external command. It’s beautiful in its simplicity:
#!/bin/sh
[ $# -eq 7 ] && /usr/bin/env chdiff –wait “$2″ “$5″
Just stick that in a script file, make it executable, set the GIT_EXTERNAL_DIFF environment variable to point at it and away you go. I’ve also documented it in the Changes.app wiki. I feel so silly for not finding this before, but the exercise in a scripted solution was good for me.
March 12th, 2008 at 14:56
I noticed a couple of typos in the script above: chdiff needs two dashes for its options and bash needs straight quotes:
#!/bin/bash
[ $# -eq 7 ] && /usr/bin/env chdiff â-wait “$2″ “$5″
More importantly, though, I’m not having any luck getting this to work with Changes:
$ git diff
diff --git a/README b/README
index a1db73c..98b2cc3 100644
--- a/README
+++ b/README
@@ -201,3 +201,4 @@ test
vendor
External libraries that the application depends on. Also includes the plugins subdirectory.
This directory is in the load path.
+testing
$ export GIT_EXTERNAL_DIFF=gitchdiff
$ git diff
Usage: chdiff (--background) (--wait)
chdiff --script
Notes: You can use process substitution for either filename1 or filename2.
To use STDIN, pass (-) for either or .
The --script parameter expects a path to a valid F-Script script.
external diff died, stopping at README.
$ cat /Users/matt/bin/gitchdiff
#!/bin/bash
[ $# -eq 7 ] && /usr/bin/env chdiff --wait “$2″ “$5″
March 12th, 2008 at 15:12
Lovely. It looks as though WordPress encoded the quotes and dash dash as html entities so a cut and past doesn’t work quite right. I suggest going to the Changes Wiki and getting the code from there.