diff lisp/diff-mode.el @ 78756:c41c1aee3d31

(diff-sanity-check-hunk): Fix up the case when unified diffs are concatenated with no intervening line.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 12 Sep 2007 05:11:07 +0000
parents b2023ab19990
children ccd0441c69e1
line wrap: on
line diff
--- a/lisp/diff-mode.el	Mon Sep 10 20:02:31 2007 +0000
+++ b/lisp/diff-mode.el	Wed Sep 12 05:11:07 2007 +0000
@@ -1181,7 +1181,16 @@
             (while
                 (case (char-after)
                   (?\s (decf before) (decf after) t)
-                  (?- (decf before) t)
+                  (?-
+                   (if (and (looking-at diff-file-header-re)
+                            (zerop before) (zerop after))
+                       ;; No need to query: this is a case where two patches
+                       ;; are concatenated and only counting the lines will
+                       ;; give the right result.  Let's just add an empty
+                       ;; line so that our code which doesn't count lines
+                       ;; will not get confused.
+                       (progn (save-excursion (insert "\n")) nil)
+                     (decf before) t))
                   (?+ (decf after) t)
                   (t
                    (cond