all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dima Kogan <dima@secretsauce.net>
To: 14516@debbugs.gnu.org
Subject: bug#14516: 24.3.50; vc-diff ignores the encoding of its input
Date: Thu, 30 May 2013 14:50:04 -0700	[thread overview]
Message-ID: <877gigt9wz.fsf@secretsauce.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1442 bytes --]

I'm using a very recent build of the emacs source repo on a Linux box.

I have a file that uses DOS-style line termination. This file is in git
and has some modifications. I use (vc-diff) to get a buffer that shows
those modifications. Currently this buffer is NOT set to use the DOS
encoding, and emacs does a conversion, so this buffer is missing the
extra CR characters the DOS encoding had. Because of this, if I save
this buffer to a file, external tools can no longer be used to apply the
patch.

I'm attaching a tiny git repository that demonstrates the issue:

 dima@shorty:/tmp$ tar xvfz vc_encoding_error_test_repo.tar.gz
 vc_encoding_error_test_repo/
 vc_encoding_error_test_repo/file
 <snip>

 dima@shorty:/tmp$ cd vc_encoding_error_test_repo

 dima@shorty:/tmp/vc_encoding_error_test_repo$ emacs --batch --eval '(progn (find-file "file") (vc-diff) (with-current-buffer "*vc-diff*" (write-file "/tmp/patch")))' -Q
 Finding changes in /tmp/vc_encoding_error_test_repo/file...
 Saving file /tmp/patch...
 Wrote /tmp/patch

 dima@shorty:/tmp/vc_encoding_error_test_repo$ git apply --cached /tmp/patch
 error: patch failed: file:1
 error: file: patch does not apply



Here we see git fail to apply the saved patch. This is due to the
stripped CR characters.

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.




[-- Attachment #2: vc_encoding_error_test_repo.tar.gz --]
[-- Type: application/octet-stream, Size: 6612 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-vc-buffers-now-use-the-encoding-of-their-input.patch --]
[-- Type: text/x-diff, Size: 860 bytes --]

From fd04b0d03f61344a4c9a37cafc86495c79a46d19 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Thu, 30 May 2013 14:17:08 -0700
Subject: [PATCH] vc buffers now use the encoding of their input

---
 lisp/vc/vc-dispatcher.el |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index 309cf50..1bada72 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -178,7 +178,9 @@ Another is that undo information is not kept."
     (setq default-directory olddir)
     (let ((buffer-undo-list t)
           (inhibit-read-only t))
-      (erase-buffer))))
+      (erase-buffer))
+    (when coding-system-for-read
+      (setq buffer-file-coding-system coding-system-for-read))))
 
 (defvar vc-sentinel-movepoint)          ;Dynamically scoped.
 
-- 
1.7.10.4


             reply	other threads:[~2013-05-30 21:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 21:50 Dima Kogan [this message]
2013-05-31  6:29 ` bug#14516: 24.3.50; vc-diff ignores the encoding of its input Richard Stallman
2013-11-25  1:27 ` Dmitry Gutov
2016-02-24  5:01   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877gigt9wz.fsf@secretsauce.net \
    --to=dima@secretsauce.net \
    --cc=14516@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.