Re: [OT] FileMerge as a vacuum
Re: [OT] FileMerge as a vacuum
- Subject: Re: [OT] FileMerge as a vacuum
- From: Greg Guerin <email@hidden>
- Date: Sun, 18 Feb 2007 14:52:38 -0700
Brad Oliver wrote:
>I do know that FileMerge gets horrifically confused if both files
>have different line endings - I've had a bug open in Radar on this
>for years now. I've found that keeping all my files with Unix line
>endings resolved this.
I use a filter, which works well enough in most other cases.
For those who never use FileMerge, ignore the following.
You need do nothing. This does not apply to you.
For those who use FileMerge, files that may or may not have CR-only
line-endings can be compared by adding a filter using the Filters pane
under Preferences. The filter has no effect on files with LF-only
line-endings, so comparisons between files with different line-endings are
easily obtained.
The peculiarities of FileMerge's use of NSTask prevent using the 'tr'
command directly in a filter. Instead, create a shell script to run 'tr',
and reference that in FileMerge's filter.
First, create a file named 'uncr' with these two lines in it:
#!/bin/sh
tr '\r' '\n' <"$1"
Then make the file executable:
chmod a+x uncr
Finally, move it to your home bin directory, or some other useful location.
If no other location comes to mind, move it to the following dir, which you
should create:
~/Library/bin/
(For the scrupulously compliant, consider this an illustration only.
Follow your conscience when it comes to compliance.)
Next, add the filter to FileMerge by double-clicking the last (empty) line
of the Filters table.
The first cell is the suffix or extension: enter html, c, h, cpp, or your
desired extension here.
The second cell is the filter command, which needs an absolute pathname.
Env-vars appear to work, so if you placed 'uncr' in ~/Library/bin, enter
this:
$(HOME)/Library/bin/uncr $(FILE)
or if you had a ~/bin directory:
$(HOME)/bin/uncr $(FILE)
The third cell selects between displaying the Filtered or Original text.
Each click on the cell toggles between Filtered and Original. Choose
Filtered.
The fourth cell is Yes to apply the filter, No to not apply it. Each click
toggles.
When this filter is applied, FileMerge is able to compare files with
different line-endings successfully, displaying the results properly.
CAUTION: This filter is imperfect - the translation is too simple-minded.
However, it's much better than having no filter at all, and doesn't require
changing CR-only line-endings on uneditable files, e.g. on read-only media.
>I believe this is because FileMerge is really
>a fancy shell on top of Unix diff, and diff (unbelievably after all
>these years) has no concept of different line endings.
FileMerge runs /usr/bin/diff. You can see this in some error or warning
messages that occasionally appear in the console log.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden