File Merge

FileMerge, the Apple diff and merge tool provided as part of XCode, is used in some cases to present various diffs for review.

Usage

To move between the different diffs, just press the arrow up and down keys on your keyboard. If nothing happens, click once on a single diff, in the middle column (where there is an arrow with a number on it).

When used to merge a diff to an output file, use the left and right arrow keys to select which version you want to keep in the output file. The left pane is the original version, and the right pane is the new version.

If you want to keep all of the new version (the right pane), you still need to press the left and right arrow keys once on one diff to force FileMerge to notice that something has changed, and thus that theere is something to save.

To save the output (merged) version (displayed in the bottom pane), just press Command-S as usual.

Known bugs and workarounds

Newer versions will ignore file encoding metadata e.g. for UTF-8 files (if known, will typically be set in xattr com.apple.TextEncoding) and instead just complain that a file is not ASCII (most of our files are not ASCII). The dialog with the error message will often be hidden, and so it appears that a script is hanging, and nothing happens. To silence FileMerge and make things work as expected, paste and run the following command in a Terminal window:

defaults write "com.apple.FileMerge" maxNonAscii -int 2147483647

The effect of this setting is to turn off the ASCII check code in FileMerge (and that test was very stupid to begin with). Thanks to Brendan Molloy for finding this workaround.

The older (and reasonable) behavior of FileMerge (and how to make sure it handles UTF-8 encoded documents correctly) is documented e.g. here.