]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/ediff-ptch.el (ediff-fixup-patch-map): Remove Git prefixes.
authorJuri Linkov <juri@linkov.net>
Sun, 5 May 2019 19:51:14 +0000 (22:51 +0300)
committerJuri Linkov <juri@linkov.net>
Sun, 5 May 2019 19:51:14 +0000 (22:51 +0300)
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

index 4178b5a8c0558ddc339f08f4968a453105e2192d..70c03b5c0133097810adb349ee8818a67d2f3043 100644 (file)
@@ -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"))