What would make hg diff see a txt file as binary?

Matt Mackall mpm at selenic.com
Sat Aug 30 08:52:13 UTC 2014


On Fri, 2014-08-29 at 18:19 -0400, Harry Putnam wrote:

> It must be control chars eh?

No. It's ABSOLUTELY a NUL byte. I wrote the code, it's right here:

http://www.selenic.com/hg/file/bdc0e04df243/mercurial/util.py#l384

It's dead simple and there is zero possibility it's anything else.

However, you're using diff. Diff compares TWO things, and one of them is
NOT in your working directory. So file(1) on the file in your working
directory is not conclusive.

> Isn't this something of an (admittedly very minor) bug for `hg diff'
> to be so gun shy? As I reported, linux `diff' didn't have that issue,
> nor did linux `file'

False:

$ diff <(printf "\0") <(printf "a")
Binary files /dev/fd/63 and /dev/fd/62 differ

$ printf "This has a null \0\n" | file -
/dev/stdin: data

$ printf "This has an escape \e\n" | file -
/dev/stdin: ASCII text, with escape sequences

-- 
Mathematics is the supreme nostalgia of our time.





More information about the Mercurial mailing list