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

From: João Távora <[email-masked]>
Date: Thu, 25 Jun 2015 14:54:26 +0100

On Wed, Jun 24, 2015 at 3:57 PM, Eli Zaretskii <[email-masked]> wrote:
>
> > From: [email-masked] (João Távora)
> > Date: Wed, 24 Jun 2015 12:29:05 +0100
> >
> >  @@ -1799,7 +1799,8 @@
> >        (with-current-buffer buf
> >       (goto-char (car pos))
> >       (delete-region (car pos) (cdr pos))
> > -     (insert (car new)))
> > +     (insert (decode-coding-string (car new)
> > +                                   buffer-file-coding-system)))
>
> That doesn't sound right: the string you are passing to
> decode-coding-string is already a multibyte string in Emacs's internal
> representation.  So decoding it one more time is not what you want.
>
> I think we should simply remove the CR characters from the end of each
> line, if buffer-file-coding-system states DOS EOL format.  (You can
> check the latter with coding-system-eol-type.)

I see my mistake now, thanks. (also thanks Stefan). It worked so I
assumed magically it's the right thing without thinking too hard. But
I don't think simply removing the CR characters is the right thing, we
should interpret them according to coding-system-eol-type, right?

It's more complicated, but I can give it a try (maybe meanwhile commit
a patch that does what you say to fix the current unusable state of
diff-apply-hunk in this situation)

So, say a diff hunk contains just a couple of lines with CRLF and a
couple of lines just LF. If applied to a buffer that is all CRLF, I
would say that applying this hunk should eventually provoke the normal
Emacs behaviour of highlighting all CR's except for the two lines with
LF. Is it worth it? What do you both think?

João