1 ;; Copyright (C) 2017 Free Software Foundation, Inc
3 ;; Author: Dima Kogan <dima@secretsauce.net>
4 ;; Maintainer: emacs-devel@gnu.org
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software: you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 (ert-deftest diff-mode-test-ignore-trailing-dashes
()
23 "Check to make sure we successfully ignore trailing -- made by
24 'git format-patch'. This is bug #9597"
26 ;; I made a test repo, put some files in it, made arbitrary changes
27 ;; and invoked 'git format-patch' to get a patch out of it. The
28 ;; patch and the before and after versions of the files appear here.
29 ;; The test simply tries to apply the patch. The patch contains
30 ;; trailing --, which confused diff-mode previously
31 (let ((patch "From 18ed35640be496647e0a02fc155b4ee4a0490eca Mon Sep 17 00:00:00 2001
32 From: Dima Kogan <dima@secretsauce.net>
33 Date: Mon, 30 Jan 2017 22:24:13 -0800
34 Subject: [PATCH] test commit
39 2 files changed, 7 deletions(-)
41 diff --git a/fil b/fil
42 index 10344f1..2a56245 100644
45 @@ -2,10 +2,8 @@ Afrocentrism
56 @@ -15,6 +13,5 @@ Aristophanes
63 diff --git a/fil2 b/fil2
64 index 8858f0d..86e8ea5 100644
92 (fil_before "Afrocentrism
113 (fil_after "Afrocentrism
131 (fil2_before "whippoorwills
152 (fil2_after "whippoorwills
169 (temp-dir (make-temp-file "diff-mode-test" 'dir
)))
171 (let ((buf (find-file-noselect (format "%s/%s" temp-dir
"fil" )))
172 (buf2 (find-file-noselect (format "%s/%s" temp-dir
"fil2"))))
175 (with-current-buffer buf
(insert fil_before
) (save-buffer))
176 (with-current-buffer buf2
(insert fil2_before
) (save-buffer))
181 (beginning-of-buffer)
186 (should (equal (with-current-buffer buf
(buffer-string))
188 (should (equal (with-current-buffer buf2
(buffer-string))
192 (with-current-buffer buf
(set-buffer-modified-p nil
))
194 (with-current-buffer buf2
(set-buffer-modified-p nil
))
196 (delete-directory temp-dir
'recursive
))))))
199 (provide 'diff-mode-tests
)