bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20892: 25.0.50; Applying vc-diff hunks on CRLF tracked files


From: João Távora
Subject: bug#20892: 25.0.50; Applying vc-diff hunks on CRLF tracked files
Date: Wed, 24 Jun 2015 12:29:05 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]