Subject: Re: bug#18236: diff-apply-hunk interacts poorly with line endings

From: Eli Zaretskii <[email-masked]>
Date: Sat, 20 Feb 2016 14:50:47 +0200

> Date: Sat, 20 Feb 2016 12:32:03 +0000
> From: Reuben Thomas <[email-masked]>
> Cc: Marcin Borkowski <[email-masked]>, [email-masked]
> 
>  The most we can do is display a warning and ask for confirmation when
>  the values of buffer-file-coding-system differ between the patch
>  file's buffer and the buffer of file to be patched. Will that be
>  sufficient?
> 
> Thanks for your analysis. ​This solution sounds fine to me: ​as you say, in general it's impossible to tell exactly
> what went wrong, but we can warn the user so that the unfortunate result I described is not obtained silently.

Marcin, would you like to work on a change along these lines?

The function to use for comparing 2 coding-systems is
`coding-system-equal'.  The idea is to see if the values of
`buffer-file-coding-system' in the patch-file buffer (where the
command is invoked) and in the buffer that visits the file to be
patched (after `find-file-noselect' call in
`diff-find-source-location' returns) are different, and if so, ask the
user for confirmation.  Ideally, the confirmation should only be
requested once, when applying the 1st hunk from the patch file.

Thanks.