]> git.eshelyaron.com Git - emacs.git/commitdiff
(diff-sanity-check-hunk): Also accept single-line hunks.
authorThien-Thi Nguyen <ttn@gnuvola.org>
Tue, 11 Sep 2007 07:00:04 +0000 (07:00 +0000)
committerThien-Thi Nguyen <ttn@gnuvola.org>
Tue, 11 Sep 2007 07:00:04 +0000 (07:00 +0000)
lisp/ChangeLog
lisp/diff-mode.el

index 2fc8aee532d8178a79e08c3eeb498aa4cb16d568..df168fae3af163de0785f9a9d0adae30dee7bdd4 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-10  Chris Moore  <dooglus@gmail.com>
+
+       * diff-mode.el (diff-sanity-check-hunk):
+       Also accept single-line hunks.
+
 2007-09-10  Chong Yidong  <cyd@stupidchicken.com>
 
        * startup.el (startup-screen-inhibit-startup-screen)
index 68f7995a494469cdc8e5be4f274473e458cbd593..d4244126f235e3d645209e9b18ecac5b3adddca2 100644 (file)
@@ -1217,26 +1217,30 @@ Only works for unified diffs."
 
        ;; A context diff.
        ((eq (char-after) ?*)
-        (if (not (looking-at "\\*\\{15\\}\\(?: .*\\)?\n\\*\\*\\* \\([0-9]+\\),\\([0-9]+\\) \\*\\*\\*\\*"))
+        (if (not (looking-at "\\*\\{15\\}\\(?: .*\\)?\n\\*\\*\\* \\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? \\*\\*\\*\\*"))
             (error "Unrecognized context diff first hunk header format")
           (forward-line 2)
           (diff-sanity-check-context-hunk-half
-           (1+ (- (string-to-number (match-string 2))
-                  (string-to-number (match-string 1)))))
-          (if (not (looking-at "--- \\([0-9]+\\),\\([0-9]+\\) ----$"))
+          (if (match-string 2)
+              (1+ (- (string-to-number (match-string 2))
+                     (string-to-number (match-string 1))))
+            1))
+          (if (not (looking-at "--- \\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? ----$"))
               (error "Unrecognized context diff second hunk header format")
             (forward-line)
             (diff-sanity-check-context-hunk-half
-             (1+ (- (string-to-number (match-string 2))
-                    (string-to-number (match-string 1))))))))
+            (if (match-string 2)
+                (1+ (- (string-to-number (match-string 2))
+                       (string-to-number (match-string 1))))
+              1)))))
 
        ;; A unified diff.
        ((eq (char-after) ?@)
         (if (not (looking-at
-                  "@@ -[0-9]+,\\([0-9]+\\) \\+[0-9]+,\\([0-9]+\\) @@"))
+                  "@@ -[0-9]+\\(?:,\\([0-9]+\\)\\)? \\+[0-9]+\\(?:,\\([0-9]+\\)\\)? @@"))
             (error "Unrecognized unified diff hunk header format")
-          (let ((before (string-to-number (match-string 1)))
-                (after (string-to-number (match-string 2))))
+          (let ((before (if (match-string 1) (string-to-number (match-string 1)) 1))
+                (after (if (match-string 2) (string-to-number (match-string 2)) 1)))
             (forward-line)
             (while
                 (case (char-after)