From 80a01d975acd7aaaa420458c057f29e46a8dbc8e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 12 Sep 2007 05:11:07 +0000 Subject: [PATCH] (diff-sanity-check-hunk): Fix up the case when unified diffs are concatenated with no intervening line. --- lisp/ChangeLog | 5 +++++ lisp/diff-mode.el | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c3d8fd8b92d..058a355a929 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2007-09-12 Stefan Monnier + + * diff-mode.el (diff-sanity-check-hunk): Fix up the case when unified + diffs are concatenated with no intervening line. + 2007-09-10 Dave Love * progmodes/python.el: Merge changes from Dave Love's v2007-Sep-10. diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el index 7cd7375ab98..ab12c6133f2 100644 --- a/lisp/diff-mode.el +++ b/lisp/diff-mode.el @@ -1181,7 +1181,16 @@ Only works for unified diffs." (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 -- 2.39.2