emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3c053ef: Filter out -L foo labels in diff-hunk-file-names


From: Lars Ingebrigtsen
Subject: master 3c053ef: Filter out -L foo labels in diff-hunk-file-names
Date: Sat, 14 Aug 2021 09:51:04 -0400 (EDT)

branch: master
commit 3c053ef14248742726e4a44dc4a809874ce76c72
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Filter out -L foo labels in diff-hunk-file-names
    
    * lisp/vc/diff-mode.el (diff-hunk-file-names): Filter out "-L foo"
    labels (bug#10160).
---
 lisp/vc/diff-mode.el            | 10 +++++-----
 test/lisp/vc/diff-mode-tests.el | 12 ++++++++++++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index bb1c46c..eeb32f8 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -969,11 +969,11 @@ If the OLD prefix arg is passed, tell the file NAME of 
the old file."
               (list (match-string 1)))
             header-files
              ;; this assumes that there are no spaces in filenames
-            (when (re-search-backward
-                   "^diff \\(-\\S-+ +\\)*\\(\\S-+\\)\\( +\\(\\S-+\\)\\)?"
-                   nil t)
-              (list (if old (match-string 2) (match-string 4))
-                    (if old (match-string 4) (match-string 2)))))))))
+             (and (re-search-backward "^diff " nil t)
+                  (looking-at
+                  "^diff \\(-[^ \t\nL]+ +\\)*\\(-L +\\S-+ +\\)*\\(\\S-+\\)\\( 
+\\(\\S-+\\)\\)?")
+                 (list (if old (match-string 3) (match-string 5))
+                       (if old (match-string 4) (match-string 3)))))))))
 
 (defun diff-find-file-name (&optional old noprompt prefix)
   "Return the file corresponding to the current patch.
diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el
index 5bc4ad6..5218659 100644
--- a/test/lisp/vc/diff-mode-tests.el
+++ b/test/lisp/vc/diff-mode-tests.el
@@ -468,4 +468,16 @@ baz"))))
                        (114 131 (diff-mode syntax face font-lock-string-face))
                        (134 140 (diff-mode syntax face 
font-lock-keyword-face))))))))
 
+(ert-deftest test-hunk-file-names ()
+  (with-temp-buffer
+    (insert "diff -c /tmp/ange-ftp13518wvE.el /tmp/ange-ftp1351895K.el\n")
+    (goto-char (point-min))
+    (should (equal (diff-hunk-file-names)
+                   '("/tmp/ange-ftp1351895K.el" "/tmp/ange-ftp13518wvE.el"))))
+  (with-temp-buffer
+    (insert "diff -c -L /ftp\:slbhao\:/home/albinus/src/tramp/lisp/tramp.el -L 
/ftp\:slbhao\:/home/albinus/src/emacs/lisp/net/tramp.el 
/tmp/ange-ftp13518wvE.el /tmp/ange-ftp1351895K.el\n")
+    (goto-char (point-min))
+    (should (equal (diff-hunk-file-names)
+                   '("/tmp/ange-ftp1351895K.el" "/tmp/ange-ftp13518wvE.el")))))
+
 (provide 'diff-mode-tests)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]