Subject: Re: bug#65049: Minor update to the repro steps

From: Dmitry Gutov <[email-masked]>
Date: Mon, 28 Aug 2023 01:32:57 +0300

On 27/08/2023 08:36, Eli Zaretskii wrote:
>> Date: Sun, 27 Aug 2023 04:14:11 +0300
>> Cc: [email-masked], [email-masked], [email-masked]
>> From: Dmitry Gutov <[email-masked]>
>>
>> On 26/08/2023 11:50, Eli Zaretskii wrote:
>>
>> I'm guessing that if we try hard enough with files encoded in an "alien"
>> coding system, we will see a similar difference between vc-diff and
>> vc-root-diff.
> 
> We could.  The 'undecided-unix' value is a good default, but if the
> fileset includes files with different incompatible encodings, there's
> no single coding-system that could satisfy that, and what Emacs
> guesses will probably be okay for the first file, but not necessarily
> for the rest.

And it only guesses when passed a file or list of them (e.g. from a 
selection in vc-dir).

>>>     . The line you suggest to remove should IMO stay, because your
>>>       suggestion is based on what you see with plain-ASCII files.  If
>>>       the files have some non-trivial text encoding, failing to use the
>>>       right encoding for the diffs will produce mojibake.  The EOL
>>>       conversion produced by vc-coding-system-for-diff is indeed
>>>       problematic, see above; but the text-conversion part is not, and
>>>       should stay.
>>>
>>> Therefore, I propose the patch below, which incorporates the above
>>> change, for the emacs-29 branch.  I think it is safe to use the 'unix
>>> EOL conversion on all systems, in the vc-git.el part of the changeset,
>>> but if you feel uneasy about that on the release branch, we could make
>>> it Windows-specific on emacs-29 and remove the condition on master.
>>
>> LGTM for emacs-29, thank you. In case anybody reports a problem, we can
>> add that OS limitation later.
> 
> Thanks, installed on the emacs-29 branch.

Thanks for the fix.

>> Regarding your paragraph above about mojibake, though. That makes a lot
>> of sense, but I feel I have to stress: this mechanism doesn't work for
>> vc-root-diff (C-x v D).
> 
> Not sure I understand.  Can you show a recipe for "doesn't work"?

It's the same recipe as what you proposed I test (a file with dos line 
ending on unix). But you don't even have to test that.

Try edebug-instrumenting vc-diff-internal and then calling vc-root-diff 
anywhere (C-x v D). When the execution reaches the line that we have 
been discussing, you'll see that (vc-coding-system-for-diff (car files)) 
evaluates to 'undecided because (car files) is a directory.

So this mechanism is always unused in vc-root-diff.