GNU bug report logs - #12584
refine diff-hunk broken for unified diff with "\ No newline at end of file" meta text

Previous Next

Package: emacs;

Reported by: Le Wang <l26wang <at> gmail.com>

Date: Sat, 6 Oct 2012 15:11:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

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 12584 in the body.
You can then email your comments to 12584 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#12584; Package emacs. (Sat, 06 Oct 2012 15:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Le Wang <l26wang <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 06 Oct 2012 15:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Le Wang <l26wang <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: refine diff-hunk broken for unified diff with "\ No newline at end of
	file" meta text
Date: Sat, 6 Oct 2012 23:09:56 +0800
Here is refine working with "diff -c"

http://puu.sh/1bXRG

Here is refein not working with "diff -u" because of the
aforementioned meta text

http://puu.sh/1bXPJ


-- 
Le




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Fri, 26 Oct 2012 15:55:02 GMT) Full text and rfc822 format available.

Notification sent to Le Wang <l26wang <at> gmail.com>:
bug acknowledged by developer. (Fri, 26 Oct 2012 15:55:02 GMT) Full text and rfc822 format available.

Message #10 received at 12584-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Le Wang <l26wang <at> gmail.com>
Cc: 12584-done <at> debbugs.gnu.org
Subject: Re: bug#12584: refine diff-hunk broken for unified diff with "\ No
	newline at end of file" meta text
Date: Fri, 26 Oct 2012 11:51:48 -0400
> Here is refine working with "diff -c"
> http://puu.sh/1bXRG
> Here is refein not working with "diff -u" because of the
> aforementioned meta text
> http://puu.sh/1bXPJ

Thank you.  I've installed the patch below which should fix this problem.


        Stefan


=== modified file 'lisp/vc/diff-mode.el'
--- lisp/vc/diff-mode.el	2012-10-23 18:40:23 +0000
+++ lisp/vc/diff-mode.el	2012-10-26 15:50:33 +0000
@@ -482,7 +482,9 @@
           (re-search-forward (if diff-valid-unified-empty-line
                                  "^[- \n]" "^[- ]")
                                      nil t nold)
-                  (line-beginning-position 2)))
+                  (line-beginning-position
+                   ;; Skip potential "\ No newline at end of file".
+                   (if (looking-at ".*\n\\\\") 3 2))))
                (endnew
                 ;; The hunk may end with a bunch of "+" lines, so the `end' is
                 ;; then further than computed above.
@@ -490,7 +492,9 @@
                   (re-search-forward (if diff-valid-unified-empty-line
                                          "^[+ \n]" "^[+ ]")
                                      nil t nnew)
-                  (line-beginning-position 2))))
+                  (line-beginning-position
+                   ;; Skip potential "\ No newline at end of file".
+                   (if (looking-at ".*\n\\\\") 3 2)))))
           (setq end (max endold endnew)))))
     ;; We may have a first evaluation of `end' thanks to the hunk header.
     (unless end
@@ -1972,7 +1976,12 @@
       (goto-char beg)
       (pcase style
         (`unified
-         (while (re-search-forward "^\\(?:-.*\n\\)+\\(\\)\\(?:\\+.*\n\\)+"
+         (while (re-search-forward
+                 (eval-when-compile
+                   (let ((no-LF-at-eol-re "\\(?:\\\\.*\n\\)?"))
+                     (concat "^\\(?:-.*\n\\)+" no-LF-at-eol-re
+                             "\\(\\)"
+                             "\\(?:\\+.*\n\\)+" no-LF-at-eol-re)))
                                    end t)
            (smerge-refine-subst (match-beginning 0) (match-end 1)
                                 (match-end 1) (match-end 0)





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 24 Nov 2012 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 296 days ago.

Previous Next


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