From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#26084: 24.5; epatch save wrong backups in Git multipatches Date: Mon, 13 Mar 2017 23:24:09 +0900 Message-ID: <87h92xdzli.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1489415119 12365 195.159.176.226 (13 Mar 2017 14:25:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 13 Mar 2017 14:25:19 +0000 (UTC) To: 26084@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 13 15:25:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnQuL-0002M5-Hi for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 Mar 2017 15:25:09 +0100 Original-Received: from localhost ([::1]:52368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnQuR-0000eR-LD for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 Mar 2017 10:25:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnQuK-0000bH-NQ for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 10:25:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnQuE-0005C2-Em for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 10:25:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55790) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cnQuE-0005Bw-Ax for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 10:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cnQuE-0007kN-5b for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 10:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Mar 2017 14:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26084 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.148941506829726 (code B ref -1); Mon, 13 Mar 2017 14:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Mar 2017 14:24:28 +0000 Original-Received: from localhost ([127.0.0.1]:53989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnQtg-0007jN-3a for submit@debbugs.gnu.org; Mon, 13 Mar 2017 10:24:28 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35867) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnQtd-0007j9-Uf for submit@debbugs.gnu.org; Mon, 13 Mar 2017 10:24:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnQtX-00053L-Fb for submit@debbugs.gnu.org; Mon, 13 Mar 2017 10:24:20 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:44744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnQtX-00053B-Cm for submit@debbugs.gnu.org; Mon, 13 Mar 2017 10:24:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnQtV-0000OU-Ui for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 10:24:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnQtS-00050z-PZ for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 10:24:17 -0400 Original-Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:34246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cnQtS-00050e-HO for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2017 10:24:14 -0400 Original-Received: by mail-pf0-x22b.google.com with SMTP id v190so69856338pfb.1 for ; Mon, 13 Mar 2017 07:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=HjKoq3aCFAqkoEJtdER0L+XITddew3WkIALBahn6HPw=; b=YK8MecXp6o0e3iwpbOwK093b551r3/tX2WhF1Y1QtLBpsZ31VKIUJJwnZixTdSyApl oMyfK2GnIle8gXgeSsb8thb4n6tZdUBNz1MzWni9Wu636yrVOuQzU02uIQW6usqjCxqd fVpCL2mJy/WN8rEt4PMELcrx/QqC/YssCA6mVXkdY6JD2VKdZ1lsUL8mEEGU5vHIW4uT z4cNfa5cdot/vYKlDcHlZrAmeEtdEuaWb7PE8nwREQXOwloVxG/GsQ1P5CjDGvIXMnfN XSn0u45F+JYkPBRFUg/fXt2BUQbbcP3kx207ZUqEFP7QQkFOEN9bT1rJW2g016mjNrE7 P44w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=HjKoq3aCFAqkoEJtdER0L+XITddew3WkIALBahn6HPw=; b=Dc8r5gL3KwprVVn8iGHmFt7YKWeX0ClKvhhWsLfF6BanjZ+LlNel+Q+8mEoNVEnTwQ YIyxznPFgfTqY+4Wz4bN/jlODvQg8ggzIj/VVwu3PI9zA+J5XXCjihzbp5CvSCj/A2HO go10XE//ZsUHsSC7pdnTOAgTKb/pE8j4eig8LXwun43bw7qjt1Z8Ssk2HnmCzfJPcY4M 4VdKhqjptappFdxv7Lq2R+mcql6OU29ur7PRYfoYp7XLfSyiZk0k0WTI7DOpKgH4qbvK 1KQ01IJXWT/Qr4uZYQ7k6hXWzNOWX/UUUMynscn0P62hO1cRcSjEOK0J0objJ8rbKD3n dhAw== X-Gm-Message-State: AMke39nIA2gkvYhF844eT1Qrle9WO/nzaSLCDyMjC2qg8APlltOM2I/y0eFXXRSpPrleLg== X-Received: by 10.84.217.2 with SMTP id o2mr48188309pli.51.1489415053244; Mon, 13 Mar 2017 07:24:13 -0700 (PDT) Original-Received: from calancha-pc (161.224.128.101.dy.bbexcite.jp. [101.128.224.161]) by smtp.gmail.com with ESMTPSA id m20sm33456195pgd.67.2017.03.13.07.24.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Mar 2017 07:24:12 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:130538 Archived-At: emacs -Q /tmp ;; Eval following form: (let ((cmd " mkdir -p foo cd foo echo 'qux here' > qux.txt echo 'bar here' > bar.txt git init git add . && git commit -m 'Test repository.' echo 'foo here' > qux.txt echo 'foo here' > bar.txt git diff > ../foo.diff git reset --hard HEAD ")) (call-process-shell-command cmd)) M-x epatch RET n /tmp/foo.diff RET /tmp/foo RET n RET q y RET q y q y ;; Eval this form: (string= (with-temp-buffer (insert-file-contents "/tmp/foo/bar.txt") (buffer-string)) (with-temp-buffer (insert-file-contents (concat "/tmp/foo/bar.txt" ediff-backup-extension)) (buffer-string))) => t ; Should be nil. --8<-----------------------------cut here---------------start------------->8--- >From 0cb7eb3d3d7cb44051ea0739bf04e34fd8ec80e7 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Mon, 13 Mar 2017 23:21:43 +0900 Subject: [PATCH] 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 proper 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. --- lisp/vc/diff-mode.el | 2 +- lisp/vc/ediff-ptch.el | 13 ++++----- test/lisp/vc/ediff-ptch-tests.el | 59 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 31c33e6a72..aa8d77882e 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -504,7 +504,7 @@ diff-end-of-hunk ;; "index ", "old mode", "new mode", "new file mode" and ;; "deleted file mode" are output by git-diff. (defconst diff-file-junk-re - (concat "Index: \\|=\\{20,\\}\\|" ; SVN + (concat "Index: \\|Prereq: \\|=\\{20,\\}\\|" ; SVN "diff \\|index \\|\\(?:deleted file\\|new\\(?: file\\)?\\|old\\) mode\\|=== modified file")) ;; If point is in a diff header, then return beginning diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el index 9d2ec51b59..36aebf4aed 100644 --- a/lisp/vc/ediff-ptch.el +++ b/lisp/vc/ediff-ptch.el @@ -25,6 +25,8 @@ ;;; Code: +(require 'diff-mode) ; For `diff-file-junk-re'. + (provide 'ediff-ptch) (defgroup ediff-ptch nil @@ -225,14 +227,11 @@ ediff-map-patch-buffer (if (and beg2 end2) (buffer-substring beg2 end2) "/dev/null"))) - ;; check for any `Index:' or `Prereq:' lines, but don't use them - (if (re-search-backward "^Index:" mark1-end 'noerror) - (move-marker mark2 (match-beginning 0))) - (if (re-search-backward "^Prereq:" mark1-end 'noerror) - (move-marker mark2 (match-beginning 0))) - + ;; Remove file junk (Bug#26084). + (while (re-search-backward + (concat "^" diff-file-junk-re) mark1-end t) + (move-marker mark2 (match-beginning 0))) (goto-char mark2-end) - (if filenames (setq patch-map (cons (ediff-make-new-meta-list-element diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el index 912c6b1e81..9aacb6bd20 100644 --- a/test/lisp/vc/ediff-ptch-tests.el +++ b/test/lisp/vc/ediff-ptch-tests.el @@ -22,7 +22,7 @@ (require 'ert) (require 'ediff-ptch) -(ert-deftest ibuffer-test-bug25010 () +(ert-deftest ediff-ptch-test-bug25010 () "Test for http://debbugs.gnu.org/25010 ." (with-temp-buffer (insert "diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el @@ -38,5 +38,62 @@ (match-string 1)))) (should-not (string-suffix-p "@@" filename))))) + +(ert-deftest ediff-ptch-test-bug26084 () + "Test for http://debbugs.gnu.org/26084 ." + (let* ((tmpdir temporary-file-directory) + (foo (expand-file-name "foo" tmpdir)) + (patch (expand-file-name "foo.diff" tmpdir)) + (qux (expand-file-name "qux.txt" foo)) + (bar (expand-file-name "bar.txt" foo)) + (cmd " +mkdir -p foo +cd foo +echo 'qux here' > qux.txt +echo 'bar here' > bar.txt +git init +git add . && git commit -m 'Test repository.' +echo 'foo here' > qux.txt +echo 'foo here' > bar.txt +git diff > ../foo.diff +git reset --hard HEAD +")) + (setq default-directory tmpdir) + (call-process-shell-command cmd) + (find-file patch) + (unwind-protect + (let* ((info + (progn (ediff-map-patch-buffer (current-buffer)) ediff-patch-map)) + (patch1 + (buffer-substring-no-properties + (car (nth 3 (car info))) + (car (nth 4 (car info))))) + (patch2 + (buffer-substring-no-properties + (car (nth 3 (cadr info))) + (car (nth 4 (cadr info)))))) + ;; Apply both patches. + (dolist (x (list (cons patch1 bar) (cons patch2 qux))) + (with-temp-buffer + (insert (car x)) + (call-shell-region (point-min) + (point-max) + (format "%s %s %s %s" + ediff-patch-program + ediff-patch-options + ediff-backup-specs + (cdr x))))) + ;; Check backup files were saved correctly. + (dolist (x (list qux bar)) + (should-not (string= (with-temp-buffer + (insert-file-contents x) + (buffer-string)) + (with-temp-buffer + (insert-file-contents (concat x ediff-backup-extension)) + (buffer-string)))))) + (delete-directory foo 'recursive) + (delete-file patch)))) + + (provide 'ediff-ptch-tests) ;;; ediff-ptch-tests.el ends here -- 2.11.0 --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.8) of 2017-03-13 Repository revision: 7a50abee22581e02f0d822c3d9684c0985cdecb2