[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e66e237: Fix up patch file names that are absolute
From: |
Lars Ingebrigtsen |
Subject: |
[elpa] master e66e237: Fix up patch file names that are absolute |
Date: |
Sun, 12 May 2019 16:33:58 -0400 (EDT) |
branch: master
commit e66e237c3ad946c5a66938a459c6e60706ef995d
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Fix up patch file names that are absolute
---
packages/debbugs/debbugs-gnu.el | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/packages/debbugs/debbugs-gnu.el b/packages/debbugs/debbugs-gnu.el
index 840b256..b77a5c2 100644
--- a/packages/debbugs/debbugs-gnu.el
+++ b/packages/debbugs/debbugs-gnu.el
@@ -2232,29 +2232,38 @@ If given a prefix, patch in the branch directory
instead."
(goto-char (point-min))
(while (re-search-forward diff-file-header-re nil t)
(goto-char (match-beginning 0))
- (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))))
- (file-exists-p (expand-file-name target-name dir))))
+ (let ((target-name (cl-loop for name in (diff-hunk-file-names)
+ ;; The target names are usually actual
+ ;; file names, but they can also be
+ ;; things like "#<buffer eww.el>".
+ unless (string-match "[ #<>]" name)
+ return name)))
+ (when target-name
+ (when (string-match "^/" target-name)
+ ;; This is an absolute path, so try to find the target.
+ (while (and (search "/" target-name)
+ (not (file-exists-p (expand-file-name target-name dir))))
+ (setq target-name (replace-regexp-in-string "^[^/]*/" ""
+ target-name))))
+ ;; See whether we can find the file.
+ (when (or (not (string-match "/" target-name))
+ (and (string-match "^[ab]/" target-name)
+ (not (file-exists-p
+ (expand-file-name (substring target-name 2)
+ dir))))
+ (file-exists-p (expand-file-name target-name 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
(file-name-nondirectory target-name))
- "$"))))
- (when (re-search-forward (concat "^[+]+ "
- (regexp-quote target-name)
- "\\([ \t\n]\\)")
- nil t)
+ "$"))))
+ (when (re-search-forward "^[+]+ .*" nil t)
(replace-match (concat "+++ a"
(substring (car files) (length dir))
(match-string 1))
- nil t)))))
+ nil t))))))
(forward-line 2)))
(defun debbugs-gnu-find-contributor (string)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master e66e237: Fix up patch file names that are absolute,
Lars Ingebrigtsen <=