emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 4bfde2a: * lisp/vc/ediff-ptch.el (ediff-fixup-patch


From: Juri Linkov
Subject: [Emacs-diffs] master 4bfde2a: * lisp/vc/ediff-ptch.el (ediff-fixup-patch-map): Remove Git prefixes.
Date: Sun, 5 May 2019 15:51:21 -0400 (EDT)

branch: master
commit 4bfde2a79046519815e2bb8a8eb72e22eca0641f
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    * lisp/vc/ediff-ptch.el (ediff-fixup-patch-map): Remove Git prefixes.
    
    Strip possible source/destination prefixes such as a/ and b/
    from directory names.   (Bug#35420)
    (ediff-fixup-patch-map, ediff-dispatch-file-patching-job)
    (ediff-patch-file-internal): Replace string-match with string-match-p.
---
 lisp/vc/ediff-ptch.el | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el
index 4178b5a..70c03b5 100644
--- a/lisp/vc/ediff-ptch.el
+++ b/lisp/vc/ediff-ptch.el
@@ -297,11 +297,24 @@ program."
              ;; file names. This is a heuristic intended to improve guessing
              (let ((default-directory (file-name-directory filename)))
                (unless (or (file-name-absolute-p base-dir1)
-                           (file-name-absolute-p base-dir2)
-                           (not (file-exists-p base-dir1))
-                           (not (file-exists-p base-dir2)))
-                 (setq base-dir1 ""
-                       base-dir2 "")))
+                           (file-name-absolute-p base-dir2))
+                 (if (and (file-exists-p base-dir1)
+                          (file-exists-p base-dir2))
+                     (setq base-dir1 ""
+                           base-dir2 "")
+                   ;; Strip possible source/destination prefixes
+                   ;; such as a/ and b/ from dir names.
+                   (save-match-data
+                     (let ((m1 (when (string-match "^[^/]+/" base-dir1)
+                                  (cons (substring base-dir1 0 (match-end 0))
+                                        (substring base-dir1 (match-end 0)))))
+                           (m2 (when (string-match "^[^/]+/" base-dir2)
+                                 (cons (substring base-dir2 0 (match-end 0))
+                                        (substring base-dir2 (match-end 0))))))
+                       (when (and (file-exists-p (cdr m1))
+                                  (file-exists-p (cdr m2)))
+                         (setq base-dir1 (car m1)
+                               base-dir2 (car m2))))))))
              (or (string= (car proposed-file-names) "/dev/null")
                  (setcar proposed-file-names
                          (ediff-file-name-sans-prefix
@@ -325,8 +338,8 @@ program."
     (mapc (lambda (session-info)
            (let ((proposed-file-names
                   (ediff-get-session-objA-name session-info)))
-             (if (and (string-match "^/null/" (car proposed-file-names))
-                      (string-match "^/null/" (cdr proposed-file-names)))
+             (if (and (string-match-p "^/null/" (car proposed-file-names))
+                      (string-match-p "^/null/" (cdr proposed-file-names)))
                  ;; couldn't intuit the file name to patch, so
                  ;; something is amiss
                  (progn
@@ -574,7 +587,7 @@ optional argument, then use it."
        (ediff-patch-file-internal
         patch-buf
         (if (and ediff-patch-map
-                 (not (string-match
+                 (not (string-match-p
                        "^/dev/null"
                        ;; this is the file to patch
                        (ediff-get-session-objA-name (car ediff-patch-map))))
@@ -677,7 +690,7 @@ optional argument, then use it."
         target-buf buf-to-patch file-name-magic-p
         patch-return-code ctl-buf backup-style aux-wind)
 
-    (if (string-match "V" ediff-patch-options)
+    (if (string-match-p "V" ediff-patch-options)
        (error
         "Ediff doesn't take the -V option in `ediff-patch-options'--sorry"))
 



reply via email to

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