Subject: bug#33567: Syntactic fontification of diff hunks

From: Juri Linkov <[email-masked]>
Date: Tue, 11 Dec 2018 02:38:18 +0200

> If you still want to reuse the literal contents of the file, as
> inserted by vc-git-find-revision etc., then you will have to duplicate
> what insert-file-contents does internally.  I suggest to look at how
> this is done in archive-set-buffer-as-visiting-file.

I looked at archive-set-buffer-as-visiting-file, and it seems it could
be simplified based on the assumption that the backend inserts output
in the binary coding.  I tried and this fixes the problem:

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 5ff9f4d5be..c980369fa9 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2042,6 +2042,7 @@ vc-find-revision-no-save
 		      (if backend
 			  (vc-call-backend backend 'find-revision file revision outbuf)
 			(vc-call find-revision file revision outbuf))))
+                  (recode-region (point-min) (point-max) buffer-file-coding-system 'binary)
                   (goto-char (point-min))
                   (if buffer (let ((buffer-file-name file)) (normal-mode)) (normal-mode))
 	          (set-buffer-modified-p nil)