From: joaotavora@gmail.com (João Távora)
To: 20892@debbugs.gnu.org
Subject: bug#20892: 25.0.50; Applying vc-diff hunks on CRLF tracked files
Date: Wed, 24 Jun 2015 12:29:05 +0100 [thread overview]
Message-ID: <jjbsi9h8hvi.fsf@gmail.com> (raw)
Hello maintainers,
1. Navigate to a repository where files are tracked with CRLF line
endings.
2. Modify one of those files.
3. Use M-x vc-root-diff. Observe how, in the latest trunk, the carriage
return (represented as ^M) are visible as a part of the diff hunk's
content. This is correct, in my opinion, if a little visually
distracting.
4. Undo of of those diffs with C-c C-a
5. Redo the same hunk with C-c C-a again
6. Notive how diff-apply-hunk incorrectly applies the carriage return
characters themselves.
Here's a trivial patch to lisp/vc/diff-mode.el, or simply cherry-pick
the commit
7ed2b6299425c4b2ea6bd8d8e8eb5eaa5e5ddf7e
which is available in this url
https://github.com/capitaomorte/emacs.git
@@ -1799,7 +1799,8 @@
(with-current-buffer buf
(goto-char (car pos))
(delete-region (car pos) (cdr pos))
- (insert (car new)))
+ (insert (decode-coding-string (car new)
+ buffer-file-coding-system)))
;; Display BUF in a window
(set-window-point (display-buffer buf) (+ (car pos) (cdr new)))
(diff-hunk-status-msg line-offset (diff-xor switched reverse) nil)
The commit message is
Consider coding system when applying diff-mode hunks.
Without this, applying hunks may garble line endings in the
destination buffer.
* lisp/vc/diff-mode.el (diff-apply-hunk): Use decode-coding-string and
buffer-file-coding-system.
Sorry I couldn't properly inline a patch,
Thanks,
João
next reply other threads:[~2015-06-24 11:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 11:29 João Távora [this message]
2015-06-24 14:52 ` bug#20892: 25.0.50; Applying vc-diff hunks on CRLF tracked files Stefan Monnier
2015-06-24 14:57 ` Eli Zaretskii
2015-06-25 13:54 ` João Távora
2015-06-25 14:41 ` Eli Zaretskii
2016-04-01 10:22 ` João Távora
2016-04-01 20:35 ` Eli Zaretskii
2016-04-01 22:51 ` João Távora
2016-04-02 9:31 ` Eli Zaretskii
2016-04-02 13:42 ` João Távora
2016-04-02 14:27 ` Eli Zaretskii
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=jjbsi9h8hvi.fsf@gmail.com \
--to=joaotavora@gmail.com \
--cc=20892@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.