Subject: Re: bug#20892: 25.0.50; Applying vc-diff hunks on CRLF tracked files

From: Eli Zaretskii <[email-masked]>
Date: Sat, 02 Apr 2016 12:31:40 +0300

> From: João Távora <[email-masked]>
> Date: Fri, 1 Apr 2016 23:51:47 +0100
> Cc: Stefan Monnier <[email-masked]>, [email-masked]
> 
> On Apr 1, 2016 21:36, "Eli Zaretskii" <[email-masked]> wrote:
> >
> > > From: [email-masked] (João Távora)
> > > Cc: [email-masked],  [email-masked]
> > > Date: Fri, 01 Apr 2016 11:22:50 +0100
> > >
> > > In lisp/vc/vc.el, in vc-diff-internal, dynamically binding
> > > `coding-system-for-read' seems to be defeated by a call to
> > > `vc-setup-buffer', which in turn kills all local variables.
> > >
> > > I don't fully understand the interaction between buffer-local and
> > > lexically/dinamically bound variables but this seems wrong, right?
> >
> > How come kill-all-local-variables can have any effect on the binding
> > of coding-system-for-read.
> 
> I don't know. I said I don't fully understand that part.
> 
> > Can you explain, or show the evidence that
> > vc-setup-buffer is the culprit here?
> 
> I edebugged and evalled coding-system-for-read before and after the
> call to vc-setup-buffer. It lost its non-nil value before and after
> the call to that vc-setup-buffer.
> 
> What may possibly have happened is that when testing I set it globally
> and hence violated some important assumption. I am away from the w32
> machine where this happened, but I will try again monday.

I cannot reproduce your result: when I edebug the relevant code,
coding-system-for-read gets bound to undecided-dos before the call to
vc-setup-buffer, and stays at that value after the call returns.

> emacs -Q bla.txt
> M-x vc-diff
> 
> The pesky ^M *and* escape sequences appear in the output. I just tried
> this on mac and the same happens. Two things fix this:
> 
> 1) The second part of my patch, to `vc-git-command'. It seems to
> respect the (apparent) fact that coding-system-for-{read,write} are
> supposed to be dynamically bindable overrides.
> 2) file-locally or dir-locally seting vc-git-commits-coding-system in
> my configuration.
> 
> >From reading the code and your messages I was under the impression
> that you agreed this was a bug. It is in my opinion (and I also think
> it is a regression).
> 
> Anyway I think 1) is a sound fix but 2) will also do the job perfectly
> well apparently. On monday I will investigate the kill-local-variables
> thing again.

Refraining from overriding coding-system-for-read/write if they are
already bound is a Good Thing, so I installed that change in the
emacs-25 branch.

However, re-reading the original bug report, I'm now confused.
Originally, you said that the ^M characters in the vc-diff output were
correct, and your problem was with applying the hunks.  If you now say
that the problem is with those ^M characters, and applying the hunks
after that is no longer a problem, then we can now close this bug.
Please clarify.