GNU bug report logs -
#14516
24.3.50; vc-diff ignores the encoding of its input
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14516 in the body.
You can then email your comments to 14516 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14516
; Package
emacs
.
(Thu, 30 May 2013 21:53:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Dima Kogan <dima <at> secretsauce.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 30 May 2013 21:53:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[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)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14516
; Package
emacs
.
(Fri, 31 May 2013 06:31:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 14516 <at> debbugs.gnu.org (full text, mbox):
I'm using a very recent build of the emacs source repo on a Linux box.
Does it run Linux alone, or does it run GNU and Linux?
--
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
Use Ekiga or an ordinary phone call
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14516
; Package
emacs
.
(Mon, 25 Nov 2013 01:28:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 14516 <at> debbugs.gnu.org (full text, mbox):
Dima Kogan <dima <at> secretsauce.net> 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).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14516
; Package
emacs
.
(Wed, 24 Feb 2016 05:03:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 14516 <at> debbugs.gnu.org (full text, mbox):
Dmitry Gutov <dgutov <at> yandex.ru> writes:
> Dima Kogan <dima <at> secretsauce.net> 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).
It looks like this was added instead:
;; On MS-Windows and MS-DOS, Diff is likely to produce DOS-style
;; EOLs, which will look ugly if (car files) happens to have Unix
;; EOLs.
(if (memq system-type '(windows-nt ms-dos))
(setq coding-system-for-read
(coding-system-change-eol-conversion coding-system-for-read
'dos)))
I guess that makes as much sense as anything. (I mean, there may be
different coding systems in each file being diffed in the same
buffer...)
So I'm closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) fixed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Wed, 24 Feb 2016 05:03:01 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
14516 <at> debbugs.gnu.org and Dima Kogan <dima <at> secretsauce.net>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Wed, 24 Feb 2016 05:03:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 23 Mar 2016 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 146 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.