Subject: bug#23595: 25.1.50; file with chinese/japanse chars, vc-diff fails (HG, Git, RCS)

From: Paul Eggert <[email-masked]>
Date: Mon, 23 May 2016 17:07:31 -0700

On 05/23/2016 03:28 PM, Dmitry Gutov wrote:
> Does it have a bug report? Can we have a test case?

Not as far as I know. I was hoping we wouldn't have to write a bug 
report now, as emacs-25 does not have that bug now. I suppose someone 
with more free time could write a test case....

>
>> One idea to improve on the
>> current emacs-25 behavior is to test whether a simple ASCII message like
>> "Binary files differ" encodes as itself using the file's coding system,
>> and to use the file's coding system if it does and locale-coding-system
>> if it doesn't.
>
> How would we do that? We're currently picking conding-system-for-read 
> well before the first byte of the output is generated.

Emacs can decide the coding system before git diff generates any output, 
by applying decode-coding-string to a canary string sample. The attached 
patch should work; please give it a try.