GNU bug report logs - #14516
24.3.50; vc-diff ignores the encoding of its input

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Thu, 30 May 2013 21:53:02 UTC

Severity: normal

Tags: fixed, patch

Found in version 24.3.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dima Kogan <dima <at> secretsauce.net>
To: 14516 <at> 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
[Message part 1 (text/plain, inline)]
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 <at> shorty:/tmp$ tar xvfz vc_encoding_error_test_repo.tar.gz
 vc_encoding_error_test_repo/
 vc_encoding_error_test_repo/file
 <snip>

 dima <at> shorty:/tmp$ cd vc_encoding_error_test_repo

 dima <at> 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 <at> 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.



[vc_encoding_error_test_repo.tar.gz (application/octet-stream, attachment)]
[0001-vc-buffers-now-use-the-encoding-of-their-input.patch (text/x-diff, attachment)]

This bug report was last modified 9 years and 147 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.