Subject: Re: bug#14516: 24.3.50; vc-diff ignores the encoding of its input

From: Dmitry Gutov <[email-masked]>
Date: Mon, 25 Nov 2013 03:27:35 +0200

Dima Kogan <[email-masked]> writes:

> VC already has code in it to detect the encoding of its input. I'm
> attaching a small patch that sets this detected encoding to the
> *vc-diff* buffer. This fixes the issue.

I'd prefer a slightly different patch.  This way, you have smaller
probability of conflict when `vc-setup-buffer' is called from any
fuction other than `vc-diff-internal'.

And `coding-system-for-read' detection is only peformed for the diff
commands.

=== modified file 'lisp/vc/vc.el'
--- lisp/vc/vc.el       2013-11-13 20:06:37 +0000
+++ lisp/vc/vc.el       2013-11-25 01:13:04 +0000
@@ -1642,6 +1642,8 @@
         (coding-system-for-read
          (if files (vc-coding-system-for-diff (car files)) 'undecided)))
     (vc-setup-buffer buffer)
+    (when coding-system-for-read
+      (setq buffer-file-coding-system coding-system-for-read))
     (message "%s" (car messages))
     ;; Many backends don't handle well the case of a file that has been
     ;; added but not yet committed to the repo (notably CVS and Subversion).