aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
diff options
context:
space:
mode:
authorTino Calancha2017-03-21 17:25:55 +0900
committerTino Calancha2017-03-21 17:25:55 +0900
commitabe731eef0fcbc59ef4836e06f6099ea17042b90 (patch)
tree6611bae15f92a0451acf7ce02128cab09d6dfb95 /test/lisp
parent205223f4725864e1fb53df5cd12694d0bc89f7d0 (diff)
downloademacs-abe731eef0fcbc59ef4836e06f6099ea17042b90.tar.gz
emacs-abe731eef0fcbc59ef4836e06f6099ea17042b90.zip
epatch: Save right backups in Git multipatches
Multipatches on N Git files save wrong backups for N-1 files; only the last one has a correct backup (Bug#26084). * lisp/vc/diff-mode.el (diff-file-junk-re): Add 'Prereq: ' * lisp/vc/ediff-ptch.el (ediff-map-patch-buffer): Use 'diff-file-junk-re'. * test/lisp/vc/ediff-ptch-tests.el (ediff-ptch-test-bug25010): Rename from ibuffer-test-bug25010. (ediff-ptch-test-bug26084): New test.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/vc/ediff-ptch-tests.el59
1 files changed, 58 insertions, 1 deletions
diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el
index 912c6b1e818..9aacb6bd20f 100644
--- a/test/lisp/vc/ediff-ptch-tests.el
+++ b/test/lisp/vc/ediff-ptch-tests.el
@@ -22,7 +22,7 @@
22(require 'ert) 22(require 'ert)
23(require 'ediff-ptch) 23(require 'ediff-ptch)
24 24
25(ert-deftest ibuffer-test-bug25010 () 25(ert-deftest ediff-ptch-test-bug25010 ()
26 "Test for http://debbugs.gnu.org/25010 ." 26 "Test for http://debbugs.gnu.org/25010 ."
27 (with-temp-buffer 27 (with-temp-buffer
28 (insert "diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el 28 (insert "diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el
@@ -38,5 +38,62 @@ index 6a07f80..6e8e947 100644
38 (match-string 1)))) 38 (match-string 1))))
39 (should-not (string-suffix-p "@@" filename))))) 39 (should-not (string-suffix-p "@@" filename)))))
40 40
41
42(ert-deftest ediff-ptch-test-bug26084 ()
43 "Test for http://debbugs.gnu.org/26084 ."
44 (let* ((tmpdir temporary-file-directory)
45 (foo (expand-file-name "foo" tmpdir))
46 (patch (expand-file-name "foo.diff" tmpdir))
47 (qux (expand-file-name "qux.txt" foo))
48 (bar (expand-file-name "bar.txt" foo))
49 (cmd "
50mkdir -p foo
51cd foo
52echo 'qux here' > qux.txt
53echo 'bar here' > bar.txt
54git init
55git add . && git commit -m 'Test repository.'
56echo 'foo here' > qux.txt
57echo 'foo here' > bar.txt
58git diff > ../foo.diff
59git reset --hard HEAD
60"))
61 (setq default-directory tmpdir)
62 (call-process-shell-command cmd)
63 (find-file patch)
64 (unwind-protect
65 (let* ((info
66 (progn (ediff-map-patch-buffer (current-buffer)) ediff-patch-map))
67 (patch1
68 (buffer-substring-no-properties
69 (car (nth 3 (car info)))
70 (car (nth 4 (car info)))))
71 (patch2
72 (buffer-substring-no-properties
73 (car (nth 3 (cadr info)))
74 (car (nth 4 (cadr info))))))
75 ;; Apply both patches.
76 (dolist (x (list (cons patch1 bar) (cons patch2 qux)))
77 (with-temp-buffer
78 (insert (car x))
79 (call-shell-region (point-min)
80 (point-max)
81 (format "%s %s %s %s"
82 ediff-patch-program
83 ediff-patch-options
84 ediff-backup-specs
85 (cdr x)))))
86 ;; Check backup files were saved correctly.
87 (dolist (x (list qux bar))
88 (should-not (string= (with-temp-buffer
89 (insert-file-contents x)
90 (buffer-string))
91 (with-temp-buffer
92 (insert-file-contents (concat x ediff-backup-extension))
93 (buffer-string))))))
94 (delete-directory foo 'recursive)
95 (delete-file patch))))
96
97
41(provide 'ediff-ptch-tests) 98(provide 'ediff-ptch-tests)
42;;; ediff-ptch-tests.el ends here 99;;; ediff-ptch-tests.el ends here