|
From: | Chris Moore |
Subject: | diff-mode doesn't like "-c0" or "-u0" diff output for single-line changes |
Date: | Sat, 8 Sep 2007 15:49:19 +0200 |
diff -c0 /tmp/1 /tmp/2
*** /tmp/1 Sat Sep 8 15:44:04 2007
--- /tmp/2 Sat Sep 8 15:44:04 2007
***************
*** 4 ****
! one
--- 4 ----
! two
and this, generated using (let ((diff-switches "-u0")) (diff "/tmp/1" "/tmp/2")) :
diff -u0 /tmp/1 /tmp/2
--- /tmp/1 2007-09-08 15:44:04.000000000 +0200
+++ /tmp/2 2007-09-08 15:44:04.000000000 +0200
@@ -4 +4 @@
-one
+two
I've fixed this bug. The fix is to make parts of the regexps optional, and to code what to do in the event that they're missing.
The patch is here: http://dooglus.rincevent.net/random/emacs-diff-patch.txt
I'll paste it here as well, in case you're reading this off-line.
I've signed papers with the FSF for my contributions to Emacs.
Chris.
-------
*** /home/chris/programs/emacs/lisp/diff-mode.el Sat Sep 8 15:29:54 2007 --- /tmp/diff-mode.el Sat Sep 8 15:40:53 2007 *************** *** 1217,1242 **** ;; A context diff. ((eq (char-after) ?*) ! (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]+\\) ----$")) (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)))))))) ;; A unified diff. ((eq (char-after) ?@) (if (not (looking-at ! "@@ -[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)))) (forward-line) (while (case (char-after) --- 1217,1246 ---- ;; A context diff. ((eq (char-after) ?*) ! (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 ! (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 ! (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]+\\)\\)? @@")) (error "Unrecognized unified diff hunk header format") ! (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)
-------
[Prev in Thread] | Current Thread | [Next in Thread] |