Commit 7fb6ce6e authored by Thien-Thi Nguyen's avatar Thien-Thi Nguyen
Browse files

(diff-sanity-check-hunk): Also accept single-line hunks.

parent 33ce5f11
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)
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment