Subject: bug#2741: Mixed UTF-8 and raw bytes in output of vc-annotate after (set-language-environment "UTF-8")

From: Juanma Barranquero <[email-masked]>
Date: Thu, 10 Sep 2009 01:18:20 +0200

On Sun, Mar 22, 2009 at 03:23, Stefan Monnier<[email-masked]> wrote:

> I don't see a mixture of anything, I just see latin-1 encoded chars
> decoded incorrectly because Emacs somehow decided to try and decode the
> stream using the utf-8 coding-system.
> But yes that's a bug.  `vc-annotate' should use the main file's
> coding-system to decode the annotated text, regardless of
> language environment.

The following patch fixes it.

The change is in `vc-annotate' and not `vc-git-annotate-command'
because the bug is not git-specific. I can easily reproduce it with
bzr, for example.

    Juanma

2009-09-09  Juanma Barranquero  <[email-masked]>

	* vc-annotate.el (vc-annotate): Use the main file's coding-system to
	decode annotated text, regardless of language environment.  (Bug#2741)

Index: vc-annotate.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-annotate.el,v
retrieving revision 1.8
diff -u -2 -r1.8 vc-annotate.el
--- vc-annotate.el	10 Mar 2009 00:59:09 -0000	1.8
+++ vc-annotate.el	9 Sep 2009 23:11:24 -0000
@@ -376,5 +376,6 @@
 		(setq temp-buffer-name (buffer-name))))
     (with-output-to-temp-buffer temp-buffer-name
-      (let ((backend (vc-backend file)))
+      (let ((backend (vc-backend file))
+	    (coding-system-for-read buffer-file-coding-system))
         (vc-call-backend backend 'annotate-command file
                          (get-buffer temp-buffer-name) rev)