> Steffen Jaeckel:
> I just tried it and got the same error and some t&r got me that it
> has something to do with a 8KB (8192byte) boundary!
> Johannes Sixt:
> As I suspected: Your filter does not consume its standard input.
> Note that clean and smudge filters do not have the liberty to
> ignore the standard input. The filter can use the file argument
> only to find out properties about the file, but the data must be
> taken from the stdin. This is particularly important for the
> smudge filter: How can you smudge the repository content when
> you read the data from the file??
> -- Hannes
Steffen, Hannes:
Thanks for your testing and feedback.
So, in looking at Hannes' advice, and re-reading the gitattributes man page, I got it to work.
My original approach was this:
clean = iconv -sc -f $(file -b --mime-encoding %f) -t utf-8 %f
smudge = iconv -sc -f utf-8 -t $(file -b --mime-encoding %f) %f
That failed about 5% of the time because iconv was told to source its input from the given file, not stdin.
So, the fix is to drop the ending %f, which implicitly tells iconv to use stdin:
clean = iconv -sc -f $(file -b --mime-encoding %f) -t utf-8
smudge = iconv -sc -f utf-8 -t $(file -b --mime-encoding %f)
This command now works for a combination of utf-16, utf-8 and standard ansi files.
Thanks again for your help!
-Ken