emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/debbugs 78ad396 157/311: Further tweaks to the patch fi


From: Stefan Monnier
Subject: [elpa] externals/debbugs 78ad396 157/311: Further tweaks to the patch fixer-upper (for a/erc.el)
Date: Sun, 29 Nov 2020 18:42:01 -0500 (EST)

branch: externals/debbugs
commit 78ad396a7b999b50a8777d737335e5dad1639977
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Further tweaks to the patch fixer-upper (for a/erc.el)
---
 debbugs-gnu.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index 296538a..034f6f6 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -1421,21 +1421,26 @@ If given a prefix, patch in the branch directory 
instead."
   (goto-char (point-min))
   (re-search-forward diff-file-header-re nil t)
   (goto-char (match-beginning 0))
-  (let ((file-names (diff-hunk-file-names)))
-    (when (and file-names
-              (not (string-match "/" (car file-names))))
+  (let ((target-name (car (diff-hunk-file-names))))
+    (when (and target-name
+              (or (not (string-match "/" target-name))
+                  (and (string-match "^[ab]/" target-name)
+                       (not (file-exists-p
+                             (expand-file-name (substring target-name 2)
+                                               dir))))))
       ;; We have a simple patch that refers to a file somewhere in the
       ;; tree.  Find it.
       (when-let ((files (directory-files-recursively
-                        dir (concat "^" (regexp-quote (car file-names))
+                        dir (concat "^" (regexp-quote
+                                         (file-name-nondirectory target-name))
                                     "$"))))
        (when (re-search-forward (concat "^[+]+ "
-                                        (regexp-quote (car file-names))
-                                        "[ \t]")
+                                        (regexp-quote target-name)
+                                        "\\([ \t\n]\\)")
                                 nil t)
          (replace-match (concat "+++ a"
                                 (substring (car files) (length dir))
-                                "\t")
+                                (match-string 1))
                         nil t))))))
 
 (defun debbugs-gnu-find-contributor (string)



reply via email to

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