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

Harry Putnam reader at newsguy.com
Sat Aug 30 17:09:04 UTC 2014


Matt Mackall <mpm at selenic.com> writes:

> 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.

OK, got it.  Thanks

> 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.

Not in the example that follows

>
>> 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

Sorry, but no, it is NOT FALSE here.

  cd [...]/merc/common/

  cp 0finaActy-snp 0finaActy-snp-orig

  Echo "this is a change" >>  0finaActy-snp

   hg diff 0finaActy-snp 
  diff -r b301bd9c1d5b common/0finaActy-snp
  Binary file common/0finaActy-snp has changed

Where as

   diff 0finaActy-snp 0finaActy-snp-orig 
  3491d3490
  < This is a change

And whereas

   file 0finaActy-snp 0finaActy-snp-orig
  0finaActy-snp:      ASCII text, with CRLF, LF line terminators, with escape sequences
  0finaActy-snp-orig: ASCII text, with CRLF, LF line terminators, with escape sequences

As we see neither the regular linux `diff' command nor `file' see a binary file
when `hg diff' does.

So no matter what kind of show you can put on with printf, here it
doesn't hold water.
   
So I repeat:

>> 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'




More information about the Mercurial mailing list