GNU bug report logs - #26028
26.0.50; epatch for multifile patches

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Arseny Sher <sher-ars@HIDDEN>; dated Wed, 8 Mar 2017 17:34:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 26028 <at> debbugs.gnu.org:


Received: (at 26028) by debbugs.gnu.org; 24 May 2017 00:47:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 23 20:47:13 2017
Received: from localhost ([127.0.0.1]:35268 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dDKSE-0004ST-RI
	for submit <at> debbugs.gnu.org; Tue, 23 May 2017 20:47:11 -0400
Received: from mail-pf0-f194.google.com ([209.85.192.194]:35436)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tino.calancha@HIDDEN>) id 1dDKSD-0004SE-05
 for 26028 <at> debbugs.gnu.org; Tue, 23 May 2017 20:47:09 -0400
Received: by mail-pf0-f194.google.com with SMTP id u26so30842836pfd.2
 for <26028 <at> debbugs.gnu.org>; Tue, 23 May 2017 17:47:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:date:to:cc:subject:in-reply-to:message-id:references
 :user-agent:mime-version;
 bh=ZAqbG0B5nFeEBSidHU7TqG0jRwFTAnOdJF+Jg5Sp8v4=;
 b=q9geL97eKOD0AFwEHErnj2zZ3LHlQErnfq3FP1fTi/17CeTsg9jhNjoDqTkvlQYHjP
 xBYqMZ0g15R9LmJjR9TBr2LVT5QEVUdwdE2JmTmh2QSWEyU/t4xV1UfzifSTw4oW5eMQ
 g8ZolGkItBr/zI3Qoa24lM4ry3U5BmrennaTOCY+t2QS/KytJf5bP6zba/1X8MbA+zFg
 F7/hM9iJqP31F9/3JASSN5IUvzyZBmo7kiElSgkAHATF3anzdGGrFnSY+xwVWMTWBHqP
 EXS1IRHu0giCCVf1/eUZ9Z/k0JT9JyW7C2M6+TNGfo/eOPMQhSXuAvu6rVB8v2VWNxU7
 bHKA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id
 :references:user-agent:mime-version;
 bh=ZAqbG0B5nFeEBSidHU7TqG0jRwFTAnOdJF+Jg5Sp8v4=;
 b=OnPQ11KjrBakwc6iAyRnB/1UVGv2ZDaP7MG39gI6LgnRoBc1Ssm/Az8I8E2WIRZ7Nd
 Ei0VkgXxbE0Wh5jrryP6CNH67h6UpOpdJSSJ24VZJwkVDyyU42xA5ND+mUZEeIslHzl4
 TuM0wNrCTnipucRL14pEWG0w3cyRWy7gFRBRTxJiXSzz9ZSXioQs0xjO6oi0dJykmA0s
 AB1TjKbYBp7KTjGiQLRrp9xKhnhkJwn3zTNCRYbguTISo07l1TNBVVDZ+OulSqXRpC+L
 RTaH91CBL/MGZSMc1aVzdcDRzqdnt8SWXt54pn9S/DbGdD6EsedbC4oprVZftjxJVH8x
 Xn/Q==
X-Gm-Message-State: AODbwcC3qErR1+ceLvxz6KJMnm3juG4rKuz2iUN/A99DpyD4D7MFXKB+
 GqZ3UKyBies3Gw==
X-Received: by 10.98.102.208 with SMTP id s77mr34536398pfj.22.1495586823082;
 Tue, 23 May 2017 17:47:03 -0700 (PDT)
Received: from calancha-pc (222.139.137.133.dy.bbexcite.jp. [133.137.139.222])
 by smtp.gmail.com with ESMTPSA id
 t66sm3578243pfe.134.2017.05.23.17.47.00
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 23 May 2017 17:47:02 -0700 (PDT)
From: Tino Calancha <tino.calancha@HIDDEN>
X-Google-Original-From: Tino Calancha <calancha@HIDDEN>
Date: Wed, 24 May 2017 09:46:59 +0900 (JST)
X-X-Sender: calancha@calancha-pc
To: Michael Heerdegen <michael_heerdegen@HIDDEN>
Subject: Re: bug#26028: 26.0.50; epatch for multifile patches
In-Reply-To: <87efvfkx9l.fsf@drachen>
Message-ID: <alpine.DEB.2.20.1705240920300.30390@calancha-pc>
References: <87varjfzhr.fsf@HIDDEN> <838tofh93b.fsf@HIDDEN>
 <87y3wfv3iy.fsf@HIDDEN> <871srfbyps.fsf@calancha-pc>
 <87efvfkx9l.fsf@drachen>
User-Agent: Alpine 2.20 (DEB 67 2015-01-07)
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset=US-ASCII
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 26028
Cc: 26028 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Kaushal Modi <kaushal.modi@HIDDEN>, Arseny Sher <sher-ars@HIDDEN>,
 Tino Calancha <tino.calancha@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)



On Wed, 24 May 2017, Michael Heerdegen wrote:

> Tino Calancha <tino.calancha@HIDDEN> writes:
>
>> Recently i am not using `epatch', but maybe following patch
>> is of interest for someone:
>
> FWIW, do you think you understood all of the code you changed (I ask
> because I gave up after a while)?
I think so.  I you exclude from the patch the added tests in
test/lisp/vc/ediff-ptch-tests.el
then this patch just touch:
2 files changed, 42 insertions(+), 18 deletions(-)
The only it does:
* tweak the original heuristic part for guessing the file names
* change the suggested defaults in the prompts asking for the patch and
   dirs to patch.

>  If you did, do you think we should
> install your fix, or are there open questions?
I have tested with plain diffs and with Git diffs.  I didn't test it
with other VC than Git.
I don't think solves all the problems, but at least it makes 
`epatch' usable for the most common multipatch situations.

I)
You know, `epatch' has never parsed multipatches with files in different 
dirs, as:
foo/file1
bar/file2

II)
The only multipatches `epatch' worked before is when all the files belong
to the same dir, as:
foo/file1
foo/file2

This patch makes possible to handle I) as well.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#26028; Package emacs. Full text available.

Message received at 26028 <at> debbugs.gnu.org:


Received: (at 26028) by debbugs.gnu.org; 23 May 2017 22:45:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 23 18:45:53 2017
Received: from localhost ([127.0.0.1]:35212 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dDIYr-0006V6-8m
	for submit <at> debbugs.gnu.org; Tue, 23 May 2017 18:45:53 -0400
Received: from mout.web.de ([212.227.15.14]:62332)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <michael_heerdegen@HIDDEN>) id 1dDIYo-0006Ur-Sf
 for 26028 <at> debbugs.gnu.org; Tue, 23 May 2017 18:45:51 -0400
Received: from drachen.dragon ([94.216.140.150]) by smtp.web.de (mrweb003
 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MDxFv-1dAlSa12Y3-00HRai; Wed, 24
 May 2017 00:45:43 +0200
From: Michael Heerdegen <michael_heerdegen@HIDDEN>
To: Tino Calancha <tino.calancha@HIDDEN>
Subject: Re: bug#26028: 26.0.50; epatch for multifile patches
References: <87varjfzhr.fsf@HIDDEN> <838tofh93b.fsf@HIDDEN>
 <87y3wfv3iy.fsf@HIDDEN> <871srfbyps.fsf@calancha-pc>
Date: Wed, 24 May 2017 00:45:42 +0200
In-Reply-To: <871srfbyps.fsf@calancha-pc> (Tino Calancha's message of "Tue, 23
 May 2017 20:26:55 +0900")
Message-ID: <87efvfkx9l.fsf@drachen>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Provags-ID: V03:K0:nGtuaRgTzsPgWKoH41btg9qEGPaPQ2ZiNmsAk/xSLSF8VgSj8YF
 sJFlRZak0uRqOv3ERA3hsugVSGEvClVxCfHSdxOGQubiSfHysxhFS4KiQhOK5zgD4mhz91v
 I20c8x/UlcNh1wzsnvaa0cIqjENlV1ycX1y17wclCgcfJY+w3H3X2D7oiiPyTNUCI1qp/Iu
 47hV9Sfygppwyvg+CiFxQ==
X-UI-Out-Filterresults: notjunk:1;V01:K0:2risK2LdM6A=:zc1XptTd8HoNKvQeFdNVNl
 //5UoXXqLAG5c4zvZM8hPTrM/4Obm28zU8+9wx9PRVG0M4ILbKnfg5+dX85B7EEBBgn9kBxFi
 6JXvdPVtjEjDkfV98evay7Ac9aCs19oEGZWXSsMxK5UafHSlevyjiV6JHL+RTAaycH/Fmc6q2
 qS02rBYevDUoVLBRdcKTPKe9+yEfBIH4FtNzerkvU0mwuWCKzVV+g9A9LmzocSkcUFYFXRWKl
 j5Sj2rLKQCXTNQcMpycngfJ4WQCbc8SZcJSVX3ILq7yQwYB/h3bliakwLBFCEHP36LnGxkqpq
 ANoOD4zm552ZxcKWHUnlZZinK7sESPdfWZg+zLYrSkG3coufkNBQdggeEvlauHhFYZNE9t96E
 EKxxz3NnwxYOe+4JbJRY5p+nPADpBjkkPItu0n+wids9MsxF+Osp7xEzDaGnp2ypZm57bQdzD
 o9ui9afn6ueZWsvWd7bRKn4oP5jaii6hKcJ/YDqhV5/P/ikf/c5d3Y8O9M2WfGcGa9qzlgxvR
 lPEJ27tT53sNm3CrTyTRDkhx9ferZRyxv50mNdYgG2prmernatoT8ENTeDSVxYmM2go6xO0zG
 3/Byxn0TKD19zi3MsEOA5xCHU248pWDOAEilJyqmQ1MGCUutj0dlKHSYSGQTRys9VkZ7stYQa
 tmoW+iwrVGLr4gtrJDJcvk4jVzTXF+kax20GMlWTaLSzZz6TJ1cbCk5Nqt+2XSEOSlqs1LlHb
 e6BT5OiaUN5QU3TAMNxWvZ26HVVQQEICx7LmenMtnLF9TicSptOZn7aT/cMZ8/L5X6ITjLdFG
 q5a0k6R
X-Spam-Score: -3.5 (---)
X-Debbugs-Envelope-To: 26028
Cc: 26028 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Arseny Sher <sher-ars@HIDDEN>, Kaushal Modi <kaushal.modi@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.5 (---)

Tino Calancha <tino.calancha@HIDDEN> writes:

> Recently i am not using `epatch', but maybe following patch
> is of interest for someone:

FWIW, do you think you understood all of the code you changed (I ask
because I gave up after a while)?  If you did, do you think we should
install your fix, or are there open questions?


Thanks,

Michael.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#26028; Package emacs. Full text available.

Message received at 26028 <at> debbugs.gnu.org:


Received: (at 26028) by debbugs.gnu.org; 23 May 2017 11:27:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 23 07:27:11 2017
Received: from localhost ([127.0.0.1]:34087 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dD7y3-0005aC-7U
	for submit <at> debbugs.gnu.org; Tue, 23 May 2017 07:27:11 -0400
Received: from mail-pf0-f169.google.com ([209.85.192.169]:36754)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tino.calancha@HIDDEN>) id 1dD7y0-0005Zy-7S
 for 26028 <at> debbugs.gnu.org; Tue, 23 May 2017 07:27:08 -0400
Received: by mail-pf0-f169.google.com with SMTP id m17so111919498pfg.3
 for <26028 <at> debbugs.gnu.org>; Tue, 23 May 2017 04:27:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=ScNIvGqZAe73x1VDW3/3+DRbAPlWJ/z4vX19PSsApUA=;
 b=io3RIcrBExi+FFGCwLz4JzWQAykEgJntBDO/g97y3V39NYcEmERCixYsRQig0SYP4c
 2jDA8VMkSLWPbXefMO6KLHDnXPzI4iLJEK4P/ky13lfnBkC7CFoce/U2hxcT0fL7f1yD
 ynJTelkVhql64JszhaVagmTW0xqoYVtV0zo0TqDgRGAD/QabZF8ZSxfDRUeqvBDTk4KW
 qbPA5c9OzlmemSOnyURRHMFZka8dw936L6V8FWAvbWwKrWCQer9VmWIsFT6wBCzc//u/
 kREnBT8Tx5lYJ19wmrp+Jy2+s3BDOR93XablmzNQ9DZsLzSLmzunfdnOLTYVAcl3SeUi
 fYIQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=ScNIvGqZAe73x1VDW3/3+DRbAPlWJ/z4vX19PSsApUA=;
 b=g+bBX9SSpZjxYzeQhKEw70YNn2w57sWPumUxHX6VMSCwByRnBkoQ073gssNtXmJmfn
 zeutM/0Maa4Lr0fIwJHbjVLVSc0u4L6HQh2ffuuujcRot5w0Lh1AVMgDPfzQ9zYjXZmN
 PdXO1WUxfz7Pri75evTC0TnXv/wnTW5rf8RWB3cSaV2iDlDRu+LoHzwCH6bTg9t2Ii8Y
 noSNbaH8SLKMuHUfcpKZxXIfqBvU0nuxdfgAzEWUxwDgEpL/fnamy9PeNeN1vSx7LXIi
 GkZj3TO/PPgoDGH2yNH2PKQ7f1XGXJ9PInuelKDZkYTkRmMZ4owkS2awIwZd9vkH9/LG
 66QA==
X-Gm-Message-State: AODbwcAv926jdt+098npviRzq4yFv75w/pSJWEtS7GRcxvt7Kwzcgxam
 OSOybUZFFaWAdw==
X-Received: by 10.99.121.13 with SMTP id u13mr31596397pgc.147.1495538822076;
 Tue, 23 May 2017 04:27:02 -0700 (PDT)
Received: from calancha-pc (222.139.137.133.dy.bbexcite.jp. [133.137.139.222])
 by smtp.gmail.com with ESMTPSA id
 x12sm1286919pgc.47.2017.05.23.04.26.59
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Tue, 23 May 2017 04:27:01 -0700 (PDT)
From: Tino Calancha <tino.calancha@HIDDEN>
To: Arseny Sher <sher-ars@HIDDEN>
Subject: Re: bug#26028: 26.0.50; epatch for multifile patches
References: <87varjfzhr.fsf@HIDDEN> <838tofh93b.fsf@HIDDEN>
 <87y3wfv3iy.fsf@HIDDEN>
Date: Tue, 23 May 2017 20:26:55 +0900
In-Reply-To: <87y3wfv3iy.fsf@HIDDEN> (Arseny Sher's message of "Thu, 09 Mar
 2017 00:53:41 +0300")
Message-ID: <871srfbyps.fsf@calancha-pc>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 26028
Cc: Michael Heerdegen <michael_heerdegen@HIDDEN>, 26028 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz@HIDDEN>, tino.calancha@HIDDEN,
 Kaushal Modi <kaushal.modi@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.8 (--)

Arseny Sher <sher-ars@HIDDEN> writes:

> Eli Zaretskii <eliz@HIDDEN> writes:
>
>> I think you should point it to ~/tmp, not ~/tmp/old.  IOW, the
>> directory should be the one relative to which the file names in the
>> patch file will correctly point to the files.
>
> Okay, it might be not very convenient (as you might have several
> versions of project inside ~/tmp, and ediff will ask you which one is to
> be patched), but it works. However, how then I am expected to apply
> patches generated by VCS, where paths are prefixed with a/ and b/?
> Again, let's consider some simple example:
>
> mkdir -p proj/src
> cd proj
> echo "void main() {}" > src/hello.c
> git init
> git add src/ && git commit -m "commit"
> echo "int main() { return 0; }" > src/hello.c
> git diff > ../tmp.patch
> git reset --hard HEAD
>
> cat ../tmp.patch
> diff --git a/src/hello.c b/src/hello.c
> index ab73b3a..76e8197 100644
> --- a/src/hello.c
> +++ b/src/hello.c
> @@ -1 +1 @@
> -void main() {}
> +int main() { return 0; }
>
> How should I apply tmp.patch to proj?
Recently i am not using `epatch', but maybe following patch
is of interest for someone:
--8<-----------------------------cut here---------------start------------->8---
commit 3f4561b160f2cc9e2b47d16e7f27fbb9b86c3f40
Author: Tino Calancha <tino.calancha@HIDDEN>
Date:   Tue May 23 19:21:42 2017 +0900

    epatch: multi-patch enhancement
    
    Handle multi-patches with files belonging to different
    subdirectories.
    (ediff-fixup-patch-map): For a multi-patch, set base-dir1 to a/
    and base-dir2 to b/ if it is a Git patch; otherwise, set both to .
    (ediff-map-patch-buffer): Use buffer-substring-no-properties.
    * lisp/vc/ediff.el (ediff-patch-file): Show differente prompt
    for multi-patches.  For single patches, use the patch header to guess the
    file to patch, and ensure the input matches an existing file.
    * test/lisp/vc/ediff-ptch-tests.el (ediff-ptch-test-bug26028): Add test.

diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el
index 0340672da2..0d53b2aff4 100644
--- a/lisp/vc/ediff-ptch.el
+++ b/lisp/vc/ediff-ptch.el
@@ -222,10 +222,10 @@ ediff-map-patch-buffer
 	    ;;     (filename-from-1st-header-line . filename-from-2nd-line)
 	    (setq possible-file-names
 		  (cons (if (and beg1 end1)
-			    (buffer-substring beg1 end1)
+			    (buffer-substring-no-properties beg1 end1)
 			  "/dev/null")
 			(if (and beg2 end2)
-			    (buffer-substring beg2 end2)
+			    (buffer-substring-no-properties beg2 end2)
 			  "/dev/null")))
             ;; Remove file junk (Bug#26084).
             (while (re-search-backward
@@ -290,18 +290,25 @@ ediff-fixup-patch-map
 		    (or (file-name-directory (cdr proposed-file-names))
 			""))
 		   )
-	      ;; If both base-dir1 and base-dir2 are relative and exist,
-	      ;; assume that
-	      ;; these dirs lead to the actual files starting at the present
-	      ;; directory. So, we don't strip these relative dirs from the
-	      ;; 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 "")))
+                (cond (multi-patch-p
+                       ;; Git diffs appends 'a/' '/b' to the files.
+                       (if (and (string-match-p "\\`a/" base-dir1)
+                                (string-match-p "\\`b/" base-dir2))
+                           (setq base-dir1 "a/" base-dir2 "b/")
+                         (setq base-dir1 "" base-dir2 "")))
+                      (t
+                       ;; If both base-dir1 and base-dir2 are relative and exist,
+                       ;; assume that
+                       ;; these dirs lead to the actual files starting at the present
+                       ;; directory. So, we don't strip these relative dirs from the
+                       ;; file names. This is a heuristic intended to improve guessing
+                       (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 "")))))
 	      (or (string= (car proposed-file-names) "/dev/null")
 		  (setcar proposed-file-names
 			  (ediff-file-name-sans-prefix
diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index 4751bb6ddc..e41839e968 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -121,6 +121,7 @@ ediff-date
 
 (require 'ediff-init)
 (require 'ediff-mult)  ; required because of the registry stuff
+(require 'diff-mode) ; diff-hunk-file-names
 
 (defgroup ediff nil
   "Comprehensive visual interface to `diff' and `patch'."
@@ -1355,6 +1356,7 @@ ediff-patch-default-directory
 (declare-function ediff-dispatch-file-patching-job "ediff-ptch"
                   (patch-buf filename &optional startup-hooks))
 
+(defvar ediff-patch-map)
 ;;;###autoload
 (defun ediff-patch-file (&optional arg patch-buf)
   "Query for a file name, and then run Ediff by patching that file.
@@ -1376,11 +1378,26 @@ ediff-patch-file
 			     (expand-file-name
 			      (buffer-file-name patch-buf))))
 			   (t default-directory)))
-    (setq source-file
-	  (read-file-name
-	   "File to patch (directory, if multifile patch): "
-	   ;; use an explicit initial file
-	   source-dir nil nil (ediff-get-default-file-name)))
+    (let ((multi-patch-p (with-current-buffer patch-buf (cdr ediff-patch-map))))
+      (cond ((not multi-patch-p)
+             (let* ((files (with-current-buffer patch-buf
+                             (diff-hunk-file-names 'old-first)))
+                    (def (if (and (string-match "\\`a/" (car files))
+                                  (string-match "\\`b/" (cadr files)))
+                             (expand-file-name
+                              (substring-no-properties (car files) 2)
+                              default-directory)
+                           (car files))))
+               (setq source-file
+                     (read-file-name
+                      "Single file to patch: "
+                      ;; use an explicit initial file
+                      source-dir nil 'mustmatch def))))
+            (t ; multi-patch
+             (setq source-file
+                   (read-file-name
+                    "Directory to patch, use root project dir: "
+                    source-dir)))))
     (ediff-dispatch-file-patching-job patch-buf source-file)))
 
 (declare-function ediff-patch-buffer-internal "ediff-ptch"
diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el
index 387786ced0..74db053c97 100644
--- a/test/lisp/vc/ediff-ptch-tests.el
+++ b/test/lisp/vc/ediff-ptch-tests.el
@@ -21,6 +21,8 @@
 
 (require 'ert)
 (require 'ediff-ptch)
+(require 'ediff-diff) ; For `ediff-diff-program'.
+(eval-when-compile (require 'cl-lib))
 
 (ert-deftest ediff-ptch-test-bug25010 ()
   "Test for http://debbugs.gnu.org/25010 ."
@@ -104,6 +106,151 @@
           (delete-directory tmpdir 'recursive)
           (delete-file patch)))))
 
+(ert-deftest ediff-ptch-test-bug26028 ()
+  "Test for http://debbugs.gnu.org/26028 ."
+  (skip-unless (executable-find "git"))
+  (skip-unless (executable-find ediff-patch-program))
+  (skip-unless (executable-find ediff-diff-program))
+  (let ((git-program (executable-find "git"))
+        (default-dir default-directory)
+        tmpdir buffers)
+    ;;; Simple patch: old/src/hello.c /new/src/hello.c
+    (unwind-protect
+        (let* ((dir (make-temp-file "multipatch-test" t))
+               (file1 (expand-file-name "old/src/hello.c" dir))
+               (file2 (expand-file-name "new/src/hello.c" dir))
+               (patch (expand-file-name "tmp.patch" dir))
+               (default-directory (file-name-as-directory dir)))
+          (setq tmpdir dir)
+          (make-directory (expand-file-name "old/src/" dir) 'parents)
+          (make-directory (expand-file-name "new/src/" dir) 'parents)
+          (with-temp-buffer
+            (insert "void main() { }\n")
+            (write-region nil nil file1 nil 'silent)
+            (erase-buffer)
+            (insert "int main() { return 0; }\n")
+            (write-region nil nil file2 nil 'silent)
+            (erase-buffer)
+            (call-process ediff-diff-program nil t nil "-cr" "old" "new")
+            (write-region nil nil patch nil 'silent)
+            (cl-letf (((symbol-function 'y-or-n-p) (lambda (x) nil))
+                      ((symbol-function 'ediff-prompt-for-patch-file)
+                       (lambda (&rest x) (find-file-noselect patch)))
+                      ((symbol-function 'read-file-name) (lambda (x1 x2 x3 x4 x5) x5))
+                      ((symbol-function 'ediff-dispatch-file-patching-job)
+                       (lambda (x y) y)))
+              (should (equal (file-relative-name file1) (epatch nil patch)))
+              (push (get-file-buffer patch) buffers))))
+      (when (file-exists-p tmpdir)
+        (setq default-directory default-dir)
+        (delete-directory tmpdir 'recursive))
+      (mapc (lambda (b)
+              (when (buffer-live-p b) (kill-buffer b)))
+            buffers)
+      (setq buffers nil))
+    ;;; Simple Git patch: proj/src/hello.c
+    (unwind-protect
+        (let* ((dir (make-temp-file "multipatch-test" t))
+               (rootdir (expand-file-name "proj/src/" dir))
+               (file (expand-file-name "hello.c" rootdir))
+               (patch (expand-file-name "tmp.patch" dir))
+               (default-directory (file-name-as-directory rootdir)))
+          (make-directory rootdir 'parents)
+          (setq tmpdir dir)
+          (with-temp-buffer
+            (insert "void main() { }\n")
+            (write-region nil nil file nil 'silent)
+            (call-process git-program nil nil nil "init")
+            (call-process git-program nil nil nil "add" ".")
+            (call-process git-program nil nil nil "commit" "-m" "test repository.")
+            (erase-buffer)
+            (insert "int main() { return 0; }\n")
+            (write-region nil nil file nil 'silent)
+            (call-process git-program nil `(:file ,patch) nil "diff")
+            (call-process git-program nil nil nil "reset" "--hard" "head")
+            (cl-letf (((symbol-function 'y-or-n-p) (lambda (x) nil))
+                      ((symbol-function 'ediff-prompt-for-patch-file)
+                       (lambda (&rest x) (find-file-noselect patch)))
+                      ((symbol-function 'read-file-name) (lambda (&rest x) file))
+                      ((symbol-function 'read-file-name) (lambda (x1 x2 x3 x4 x5) x5))
+                      ((symbol-function 'ediff-dispatch-file-patching-job)
+                       (lambda (x y) y)))
+              (should (equal file (epatch nil patch)))))
+          (push (get-file-buffer patch) buffers))
+      ;; clean up
+      (when (file-exists-p tmpdir)
+        (setq default-directory default-dir)
+        (delete-directory tmpdir 'recursive))
+      (mapc (lambda (b)
+              (when (buffer-live-p b) (kill-buffer b)))
+            buffers)
+      (setq buffers nil))
+    ;;; Git multipatch.
+    (unwind-protect
+        (let* ((dir (make-temp-file "multipatch-test" t))
+               (file1 (expand-file-name "proj/src/hello.c" dir))
+               (file2 (expand-file-name "proj/src/bye.c" dir))
+               (file3 (expand-file-name "proj/lisp/foo.el" dir))
+               (file4 (expand-file-name "proj/lisp/bar.el" dir))
+               (file5 (expand-file-name "proj/etc/news" dir))
+               (patch (expand-file-name "tmp.patch" dir))
+               (default-directory (expand-file-name "proj" dir)))
+          (setq tmpdir dir)
+          (dolist (d '("src" "lisp" "etc"))
+            (setq rootdir (expand-file-name (concat "proj/" d) dir))
+            (make-directory rootdir 'parents))
+          (with-temp-buffer
+            (insert "void main() { }\n")
+            (write-region nil nil file1 nil 'silent)
+            (write-region nil nil file2 nil 'silent)
+            (erase-buffer)
+            (insert "(defun foo () nil)\n")
+            (write-region nil nil file3 nil 'silent)
+            (erase-buffer)
+            (insert "(defun bar () nil)\n")
+            (write-region nil nil file4 nil 'silent)
+            (erase-buffer)
+            (insert "new functions 'foo' and 'bar'\n")
+            (write-region nil nil file5 nil 'silent)
+            (call-process git-program nil nil nil "init")
+            (call-process git-program nil nil nil "add" "src" "lisp" "etc")
+            (call-process git-program nil nil nil "commit" "-m" "test repository.");)
+            (erase-buffer)
+            (insert "int main() { return 0;}\n")
+            (write-region nil nil file1 nil 'silent)
+            (write-region nil nil file2 nil 'silent)
+            (erase-buffer)
+            (insert "(defun qux () nil)\n")
+            (write-region nil nil file3 nil 'silent)
+            (erase-buffer)
+            (insert "(defun quux () nil)\n")
+            (write-region nil nil file4 nil 'silent)
+            (erase-buffer)
+            (insert "new functions 'qux' and 'quux'\n")
+            (write-region nil nil file5 nil 'silent)
+            (call-process git-program nil `(:file ,patch) nil "diff")
+            (call-process git-program nil nil nil "reset" "--hard" "head"))
+          (cl-letf (((symbol-function 'y-or-n-p) (lambda (x) nil))
+                    ((symbol-function 'ediff-get-patch-file) (lambda (&rest x) patch))
+                    ((symbol-function 'read-file-name) (lambda (&rest x) patch)))
+            (epatch nil patch)
+            (with-current-buffer "*Ediff Session Group Panel*"
+              (push (get-file-buffer patch) buffers)
+              (should (= 5 (length (cdr ediff-meta-list))))
+              ;; don't ask confirmation to exit.
+              (cl-letf (((symbol-function 'y-or-n-p) (lambda (x) t)))
+                (ediff-quit-meta-buffer)))))
+      ;; clean up
+      (when (file-exists-p tmpdir)
+        (setq default-directory default-dir)
+        (delete-directory tmpdir 'recursive))
+      (when ediff-registry-buffer
+        (push ediff-registry-buffer buffers))
+      (mapc (lambda (b)
+              (when (buffer-live-p b) (kill-buffer b)))
+            buffers)
+      (setq buffers nil))))
+
 
 (provide 'ediff-ptch-tests)
 ;;; ediff-ptch-tests.el ends here
--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-05-23
Repository revision: 4a485410ce74cafd4e9c344e31f7575464a16113





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#26028; Package emacs. Full text available.

Message received at 26028 <at> debbugs.gnu.org:


Received: (at 26028) by debbugs.gnu.org; 9 Mar 2017 11:44:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 09 06:44:25 2017
Received: from localhost ([127.0.0.1]:47198 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1clwUb-0001xD-EB
	for submit <at> debbugs.gnu.org; Thu, 09 Mar 2017 06:44:25 -0500
Received: from forward1m.cmail.yandex.net ([5.255.216.2]:47474)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sher-ars@HIDDEN>) id 1clwUZ-0001wz-NH
 for 26028 <at> debbugs.gnu.org; Thu, 09 Mar 2017 06:44:24 -0500
Received: from smtp1m.mail.yandex.net (smtp1m.mail.yandex.net
 [IPv6:2a02:6b8:0:2519::121])
 by forward1m.cmail.yandex.net (Yandex) with ESMTP id E3BAA20D26;
 Thu,  9 Mar 2017 14:44:16 +0300 (MSK)
Received: from smtp1m.mail.yandex.net (localhost.localdomain [127.0.0.1])
 by smtp1m.mail.yandex.net (Yandex) with ESMTP id 9E88D63C0E9F;
 Thu,  9 Mar 2017 14:44:12 +0300 (MSK)
Received: by smtp1m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id
 sbLWuDSpMU-iBYqOpR3; Thu, 09 Mar 2017 14:44:11 +0300
 (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits))
 (Client certificate not present)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1489059851; bh=rLTDGiizMyUtFMRkNpdIBLll5NiFPJzgFV6lhB3V+E4=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID;
 b=esXEzg20dcnZIc0llkDzIpc+MRaae7cZsNDjLMng+ICtLqfOtvZyMJj6tfmkZNjIr
 uaysIs5SFaxf7xpX0OZPtR8ZaYfpihD/sAee3eW+c6EED6OqBQvyCKFESJZE8C3UHE
 kE1ImMFQCekhY0KCCfSQGqwE6mz5fk6vczIQJt40=
Authentication-Results: smtp1m.mail.yandex.net; dkim=pass header.i=@yandex.ru
X-Yandex-Suid-Status: 1 0,1 0,1 0,1 0
From: Arseny Sher <sher-ars@HIDDEN>
To: Tino Calancha <tino.calancha@HIDDEN>
Subject: Re: bug#26028: 26.0.50; epatch for multifile patches
References: <87varjfzhr.fsf@HIDDEN> <838tofh93b.fsf@HIDDEN>
 <87y3wfv3iy.fsf@HIDDEN> <87d1drfcqp.fsf@calancha-pc>
Date: Thu, 09 Mar 2017 14:44:11 +0300
In-Reply-To: <87d1drfcqp.fsf@calancha-pc> (Tino Calancha's message of "Thu, 09
 Mar 2017 10:41:18 +0900")
Message-ID: <87shmmvfn8.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 26028
Cc: Michael Heerdegen <michael_heerdegen@HIDDEN>, 26028 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Tino Calancha <tino.calancha@HIDDEN> writes:

>> How should I apply tmp.patch to proj?
> Ediff uses the `default-directory' for the patch buffer as a hint.
> When i apply patches generated with VCS i _always_ set the
> `default-directory' of the patch buffer equal as the root directory of
> the project.  That makes multi patches work OK.
> This is how i would do in your exmple:
> M-: (dired "/tmp/proj") RET
> C-x b *p* RET ; Now copy the patch here in your favourite way.
> C-x 4 r /tmp/tmp.patch RET
> C-x h M-w C-x o C-y
> M-x epatch RET y *p* RET /tmp/proj/src RET

Honestly, I didn't understand your answer.
1) I don't see any effects of changing the default directory. I set
   default directory of buffer with patch to ~/tmp/proj as you say, then
   run epatch, firstly point it to this buffer, then specify ~/tmp/proj
   (because this is project root, and I want to patch the whole project!)
   as target directory and it fails again, exactly as before.
2) Interpreting your instructions literally, I should specify
   ~/tmp/proj/src as target directory to ediff (answer to its last
   question). Well, then it works, but this is precisely the behaviour
   which doesn't make any sense to me: ediff just ignores the path to
   file ('src' directory here). And it happens totally independent of
   default directory value, I tried with different ones.
   I suppose that the whole point of applying multifile patch is to allow
   ediff deduce which files (with full paths) it needs to patch
   automatically, without manually specifying dirs like 'src'. Imagine
   we have also hello.h file under proj/include; then, if I tell ediff
   to use ~/tmp/proj/src dir as target directory as you say, it will
   successfully patch hello.c, but it will fail again attempting to
   patch hello.h, because there is no such file proj/src/hello.h.

So, it is hard for me to suggest better epatch behaviour because I
actually don't comprehend its current one. I don't know why other people
don't encounter these problems. Probably they just apply patches via git
and only then look at the diff via ediff, and I should go the same
way...





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#26028; Package emacs. Full text available.

Message received at 26028 <at> debbugs.gnu.org:


Received: (at 26028) by debbugs.gnu.org; 9 Mar 2017 01:41:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 08 20:41:30 2017
Received: from localhost ([127.0.0.1]:46894 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cln58-0007eP-Jq
	for submit <at> debbugs.gnu.org; Wed, 08 Mar 2017 20:41:30 -0500
Received: from mail-pg0-f68.google.com ([74.125.83.68]:35924)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tino.calancha@HIDDEN>) id 1cln57-0007eA-9a
 for 26028 <at> debbugs.gnu.org; Wed, 08 Mar 2017 20:41:29 -0500
Received: by mail-pg0-f68.google.com with SMTP id 25so5043345pgy.3
 for <26028 <at> debbugs.gnu.org>; Wed, 08 Mar 2017 17:41:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=NaEyJDCIJJ54qBrPMJWETcbC7WV05KF8m/ehN5zwmHc=;
 b=DevZkp+ViUx5Hv5LJeTYLSnH45ukCYl1rCAyzQ7ByznqwE/35bL/tmN28kiAhfhGG9
 rDFQpOsAXH1p3G4N35dkadRDpxOyQavVIwgZpTca3DziUCW5pNc+Iuqdyp7/Yk+yY0xy
 zTw9olvCzGHZpqt6d6e1jzuqTMV6lC8IbanUOmT8pmAk3slNX4PssA1RSwEtRlZ37xON
 rjPVLarVltn/q/Y5wQT4Kw8r3pCukRHjsyUGwVAJHqwfpTX5sTbcrWH6UUjDmZlRt9Sg
 htE8+ZwZajTUJSFJ4f23PBGejUXbqCVftWt9iESrlHYG8v0zkiV0Ld0gDzQYpPknNHdS
 cxbA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=NaEyJDCIJJ54qBrPMJWETcbC7WV05KF8m/ehN5zwmHc=;
 b=KgXPIX7t79pJ49kKDsskYQreoRRQwQIXqoSKisG6OGZAF/k+iXHPI/ktE5waGGgT1w
 QXOGvR0mCV0X/el24OqqesVl1/zCnSqthg29nK5I4NvT/vvZ6c0lEF+JWw6NkrvNlc4o
 inr7rNW4WSPGOyM78lHgCBoabYuQIvrg1U1S4vCMOG6yQ2Rd4W3QDVw6ITnoDllyiM5K
 WbZ3XiVHbEQciftkhwwu/C98O8bba0HKY7g2cspwUnWt72GcjCkiscRNRT7B/y25Tzfl
 XWIr1556/hjKlUroOn/Y4GgWvljp2Hhw1j4R+pGteHMy1gmnGMmn4yvWGcnZa0dCtuqr
 6OLw==
X-Gm-Message-State: AMke39mfdGipR0VrA3+cOqD1Z+BsDnwl8bbK8I+u38ls5ztgWNtKtHQwXPrckBzLQXGGQw==
X-Received: by 10.84.210.15 with SMTP id z15mr13264740plh.11.1489023683282;
 Wed, 08 Mar 2017 17:41:23 -0800 (PST)
Received: from calancha-pc (128.126.156.220.dy.bbexcite.jp. [220.156.126.128])
 by smtp.gmail.com with ESMTPSA id
 129sm8420313pgj.59.2017.03.08.17.41.20
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Wed, 08 Mar 2017 17:41:22 -0800 (PST)
From: Tino Calancha <tino.calancha@HIDDEN>
To: Arseny Sher <sher-ars@HIDDEN>
Subject: Re: bug#26028: 26.0.50; epatch for multifile patches
References: <87varjfzhr.fsf@HIDDEN> <838tofh93b.fsf@HIDDEN>
 <87y3wfv3iy.fsf@HIDDEN>
Date: Thu, 09 Mar 2017 10:41:18 +0900
In-Reply-To: <87y3wfv3iy.fsf@HIDDEN> (Arseny Sher's message of "Thu, 09 Mar
 2017 00:53:41 +0300")
Message-ID: <87d1drfcqp.fsf@calancha-pc>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 1.8 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Arseny Sher writes: > How then I am expected to apply >
 patches
 generated by VCS, where paths are prefixed with a/ and b/? Ediff will skip
 those 'a/', 'b/' automatically. > Again, let's consider some simple example:
 > > mkdir -p proj/src > cd proj > echo "void main() {}" > src/hello.c > git
 init > git add src/ && git commit -m "commit" > echo "int main() { return
 0; }" > src/hello.c > git diff > ../tmp.patch > git reset --hard HEAD > >
 cat ../tmp.patch > diff --git a/src/hello.c b/src/hello.c > index
 ab73b3a..76e8197
 100644 > --- a/src/hello.c > +++ b/src/hello.c > @@ -1 +1 @@ > -void main()
 {} > +int main() { return 0; } > > How should I apply tmp.patch to proj?
 Ediff uses the `default-directory' for the patch buffer as a hint. When i
 apply patches generated with VCS i _always_ set the `default-directory' of
 the patch buffer equal as the root directory of the project. That makes multi
 patches work OK. This is how i would do in your exmple: M-: (dired
 "/tmp/proj")
 RET C-x b *p* RET ; Now copy the patch here in your favourite way. C-x 4
 r /tmp/tmp.patch RET C-x h M-w C-x o C-y M-x epatch RET y *p* RET
 /tmp/proj/src RET [...] 
 Content analysis details:   (1.8 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.5 RCVD_IN_SORBS_SPAM     RBL: SORBS: sender is a spam source
 [74.125.83.68 listed in dnsbl.sorbs.net]
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at http://www.dnswl.org/, no
 trust [74.125.83.68 listed in list.dnswl.org]
 -0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)
 [74.125.83.68 listed in wl.mailspike.net]
 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider
 (tino.calancha[at]gmail.com)
 -0.0 SPF_PASS               SPF: sender matches SPF record
 1.3 URI_HEX                URI: URI hostname has long hexadecimal sequence
 0.0 T_DKIM_INVALID         DKIM-Signature header exists but is not valid
 -0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders
X-Debbugs-Envelope-To: 26028
Cc: Michael Heerdegen <michael_heerdegen@HIDDEN>, 26028 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz@HIDDEN>, tino.calancha@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.8 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Arseny Sher writes: > How then I am expected to apply > patches
    generated by VCS, where paths are prefixed with a/ and b/? Ediff will skip
    those 'a/', 'b/' automatically. > Again, let's consider some simple example:
    > > mkdir -p proj/src > cd proj > echo "void main() {}" > src/hello.c > git
    init > git add src/ && git commit -m "commit" > echo "int main() { return
    0; }" > src/hello.c > git diff > ../tmp.patch > git reset --hard HEAD > >
    cat ../tmp.patch > diff --git a/src/hello.c b/src/hello.c > index ab73b3a..76e8197
    100644 > --- a/src/hello.c > +++ b/src/hello.c > @@ -1 +1 @@ > -void main()
    {} > +int main() { return 0; } > > How should I apply tmp.patch to proj?
   Ediff uses the `default-directory' for the patch buffer as a hint. When i
   apply patches generated with VCS i _always_ set the `default-directory' of
    the patch buffer equal as the root directory of the project. That makes multi
    patches work OK. This is how i would do in your exmple: M-: (dired "/tmp/proj")
    RET C-x b *p* RET ; Now copy the patch here in your favourite way. C-x 4
   r /tmp/tmp.patch RET C-x h M-w C-x o C-y M-x epatch RET y *p* RET /tmp/proj/src
    RET [...] 
 
 Content analysis details:   (1.8 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)
                             [74.125.83.68 listed in wl.mailspike.net]
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at http://www.dnswl.org/, no
                             trust
                             [74.125.83.68 listed in list.dnswl.org]
  0.5 RCVD_IN_SORBS_SPAM     RBL: SORBS: sender is a spam source
                             [74.125.83.68 listed in dnsbl.sorbs.net]
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail provider
                             (tino.calancha[at]gmail.com)
 -0.0 SPF_PASS               SPF: sender matches SPF record
  1.3 URI_HEX                URI: URI hostname has long hexadecimal sequence
  0.0 T_DKIM_INVALID         DKIM-Signature header exists but is not valid
 -0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders

Arseny Sher <sher-ars@HIDDEN> writes:

> How then I am expected to apply
> patches generated by VCS, where paths are prefixed with a/ and b/?
Ediff will skip those 'a/', 'b/' automatically.
> Again, let's consider some simple example:
>
> mkdir -p proj/src
> cd proj
> echo "void main() {}" > src/hello.c
> git init
> git add src/ && git commit -m "commit"
> echo "int main() { return 0; }" > src/hello.c
> git diff > ../tmp.patch
> git reset --hard HEAD
>
> cat ../tmp.patch
> diff --git a/src/hello.c b/src/hello.c
> index ab73b3a..76e8197 100644
> --- a/src/hello.c
> +++ b/src/hello.c
> @@ -1 +1 @@
> -void main() {}
> +int main() { return 0; }
>
> How should I apply tmp.patch to proj?
Ediff uses the `default-directory' for the patch buffer as a hint.
When i apply patches generated with VCS i _always_ set the
`default-directory' of the patch buffer equal as the root directory of
the project.  That makes multi patches work OK.
This is how i would do in your exmple:
M-: (dired "/tmp/proj") RET
C-x b *p* RET ; Now copy the patch here in your favourite way.
C-x 4 r /tmp/tmp.patch RET
C-x h M-w C-x o C-y
M-x epatch RET y *p* RET /tmp/proj/src RET

> Yet am not still sure that this is not a bug; some other guy said that
> this behaviour doesn't make sense, and similar bug was fixed recently:
> http://lists.gnu.org/archive/html/help-gnu-emacs/2017-03/msg00064.html
> http://emacs.1067599.n8.nabble.com/bug-25010-26-0-50-epatch-might-parse-wrongly-a-file-name-td413747.html
I tend to agree that it might be possible to improve how Ediff
handle these things.  That said, as a user i haven't being disturbed
so much by this inconvenience.  I am also worry if i could break other
important feature while trying to improve this; that's essentially why
i didn't try hard to work in this issue.

If you have some an idea about how to prepare a patch improving
Ediff on this area i am welcome to support you in that task.

Regards,
Tino




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#26028; Package emacs. Full text available.

Message received at 26028 <at> debbugs.gnu.org:


Received: (at 26028) by debbugs.gnu.org; 8 Mar 2017 21:53:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 08 16:53:53 2017
Received: from localhost ([127.0.0.1]:46793 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cljWr-0000o1-Em
	for submit <at> debbugs.gnu.org; Wed, 08 Mar 2017 16:53:53 -0500
Received: from forward3m.cmail.yandex.net ([5.255.216.21]:50159)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sher-ars@HIDDEN>) id 1cljWp-0000nn-GY
 for 26028 <at> debbugs.gnu.org; Wed, 08 Mar 2017 16:53:52 -0500
Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net
 [IPv6:2a02:6b8:0:1a2d::25])
 by forward3m.cmail.yandex.net (Yandex) with ESMTP id AE79C216E3;
 Thu,  9 Mar 2017 00:53:44 +0300 (MSK)
Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1])
 by smtp1o.mail.yandex.net (Yandex) with ESMTP id 283B61300C13;
 Thu,  9 Mar 2017 00:53:43 +0300 (MSK)
Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id
 5PF9iSI40Z-rguOOMbm; Thu, 09 Mar 2017 00:53:42 +0300
 (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits))
 (Client certificate not present)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1489010022; bh=myB87SytBKvX1gpUX3/GnXmaWJGwGmShSR0ZASfO+ck=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID;
 b=sKmroETg31kH/s1ww2K+TNCecu/UEyRSeWEIiOW+SjSZycaogGuN0JpfSy5z0luBY
 1tJi0y09P89JdkJLJ++EjSY53RzXQXLk3UkA5ofIgHVFevd/vHSs0poUNgVBpt2BMg
 m+5AWtgQv1GCt9EjquMXYoD2hKZZ9yCemK35DO5E=
Authentication-Results: smtp1o.mail.yandex.net; dkim=pass header.i=@yandex.ru
X-Yandex-Suid-Status: 1 0,1 0
From: Arseny Sher <sher-ars@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#26028: 26.0.50; epatch for multifile patches
References: <87varjfzhr.fsf@HIDDEN> <838tofh93b.fsf@HIDDEN>
Date: Thu, 09 Mar 2017 00:53:41 +0300
In-Reply-To: <838tofh93b.fsf@HIDDEN> (Eli Zaretskii's message of "Wed, 08 Mar
 2017 21:17:12 +0200")
Message-ID: <87y3wfv3iy.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.6 (/)
X-Debbugs-Envelope-To: 26028
Cc: 26028 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.6 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> I think you should point it to ~/tmp, not ~/tmp/old.  IOW, the
> directory should be the one relative to which the file names in the
> patch file will correctly point to the files.

Okay, it might be not very convenient (as you might have several
versions of project inside ~/tmp, and ediff will ask you which one is to
be patched), but it works. However, how then I am expected to apply
patches generated by VCS, where paths are prefixed with a/ and b/?
Again, let's consider some simple example:

mkdir -p proj/src
cd proj
echo "void main() {}" > src/hello.c
git init
git add src/ && git commit -m "commit"
echo "int main() { return 0; }" > src/hello.c
git diff > ../tmp.patch
git reset --hard HEAD

cat ../tmp.patch
diff --git a/src/hello.c b/src/hello.c
index ab73b3a..76e8197 100644
--- a/src/hello.c
+++ b/src/hello.c
@@ -1 +1 @@
-void main() {}
+int main() { return 0; }

How should I apply tmp.patch to proj?

Yet am not still sure that this is not a bug; some other guy said that
this behaviour doesn't make sense, and similar bug was fixed recently:
http://lists.gnu.org/archive/html/help-gnu-emacs/2017-03/msg00064.html
http://emacs.1067599.n8.nabble.com/bug-25010-26-0-50-epatch-might-parse-wrongly-a-file-name-td413747.html

And while I am here, I would like to express my gratitude to ediff
developers; it is in overall a great tool, and it is a pleasure to read
its manual. Thank you guys!




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#26028; Package emacs. Full text available.

Message received at 26028 <at> debbugs.gnu.org:


Received: (at 26028) by debbugs.gnu.org; 8 Mar 2017 19:17:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 08 14:17:48 2017
Received: from localhost ([127.0.0.1]:46658 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1clh5o-0003Rk-Ci
	for submit <at> debbugs.gnu.org; Wed, 08 Mar 2017 14:17:48 -0500
Received: from eggs.gnu.org ([208.118.235.92]:58094)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1clh5n-0003RY-4g
 for 26028 <at> debbugs.gnu.org; Wed, 08 Mar 2017 14:17:47 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1clh5e-0000Hf-Qx
 for 26028 <at> debbugs.gnu.org; Wed, 08 Mar 2017 14:17:42 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:34173)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1clh5e-0000Ha-NS; Wed, 08 Mar 2017 14:17:38 -0500
Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1507
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1clh5d-00061c-Lt; Wed, 08 Mar 2017 14:17:38 -0500
Date: Wed, 08 Mar 2017 21:17:12 +0200
Message-Id: <838tofh93b.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Arseny Sher <sher-ars@HIDDEN>
In-reply-to: <87varjfzhr.fsf@HIDDEN> (message from Arseny Sher on Wed, 08
 Mar 2017 20:29:52 +0300)
Subject: Re: bug#26028: 26.0.50; epatch for multifile patches
References: <87varjfzhr.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 26028
Cc: 26028 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

> From: Arseny Sher <sher-ars@HIDDEN>
> Date: Wed, 08 Mar 2017 20:29:52 +0300
> 
> ars@ars-thinkpad ~/tmp $ mkdir -p old/src
> ars@ars-thinkpad ~/tmp $ echo "void main() { }" > old/src/hello.c
> ars@ars-thinkpad ~/tmp $ mkdir -p new/src
> ars@ars-thinkpad ~/tmp $ echo "int main() { return 0; }" > new/src/hello.c
> ars@ars-thinkpad ~/tmp $ diff -cr old/ new/ > tmp.patch
> ars@ars-thinkpad ~/tmp $ cat tmp.patch
> diff -cr old/src/hello.c new/src/hello.c
> *** old/src/hello.c	2017-03-08 14:29:24.743846995 +0300
> --- new/src/hello.c	2017-03-08 14:29:32.399846824 +0300
> ***************
> *** 1 ****
> ! void main() { }
> --- 1 ----
> ! int main() { return 0; }
> 
> 
> Now I start emacs and do M-x epatch. First of all, it asks me for
> patch buffer or file, I point to '~/tmp/tmp.patch'. Then it asks for
> directory to patch, I say '~/tmp/old' and ediff complains
> 
> Ediff has inferred that
> 	/home/ars/tmp/old/hello.c
> is assumed to be the target for this patch.  However, this file does not exist.

I think you should point it to ~/tmp, not ~/tmp/old.  IOW, the
directory should be the one relative to which the file names in the
patch file will correctly point to the files.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#26028; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Mar 2017 17:33:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 08 12:33:11 2017
Received: from localhost ([127.0.0.1]:46565 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1clfSY-0006wX-VH
	for submit <at> debbugs.gnu.org; Wed, 08 Mar 2017 12:33:11 -0500
Received: from eggs.gnu.org ([208.118.235.92]:43930)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sher-ars@HIDDEN>) id 1clfPd-0006qH-TM
 for submit <at> debbugs.gnu.org; Wed, 08 Mar 2017 12:30:11 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <sher-ars@HIDDEN>) id 1clfPW-0007q5-TR
 for submit <at> debbugs.gnu.org; Wed, 08 Mar 2017 12:30:04 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:36222)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <sher-ars@HIDDEN>) id 1clfPW-0007q1-QU
 for submit <at> debbugs.gnu.org; Wed, 08 Mar 2017 12:30:02 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34894)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <sher-ars@HIDDEN>) id 1clfPU-0000Ov-Mx
 for bug-gnu-emacs@HIDDEN; Wed, 08 Mar 2017 12:30:02 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <sher-ars@HIDDEN>) id 1clfPR-0007pB-EF
 for bug-gnu-emacs@HIDDEN; Wed, 08 Mar 2017 12:30:00 -0500
Received: from forward13h.cmail.yandex.net ([87.250.230.155]:51185)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <sher-ars@HIDDEN>) id 1clfPQ-0007o2-Sh
 for bug-gnu-emacs@HIDDEN; Wed, 08 Mar 2017 12:29:57 -0500
Received: from smtp2h.mail.yandex.net (smtp2h.mail.yandex.net
 [IPv6:2a02:6b8:0:f05::116])
 by forward13h.cmail.yandex.net (Yandex) with ESMTP id 624022209A
 for <bug-gnu-emacs@HIDDEN>; Wed,  8 Mar 2017 20:29:54 +0300 (MSK)
Received: from smtp2h.mail.yandex.net (localhost.localdomain [127.0.0.1])
 by smtp2h.mail.yandex.net (Yandex) with ESMTP id 4D7427819F6
 for <bug-gnu-emacs@HIDDEN>; Wed,  8 Mar 2017 20:29:53 +0300 (MSK)
Received: by smtp2h.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id
 OZKz1EonFv-TrRaV1qC; Wed, 08 Mar 2017 20:29:53 +0300
 (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits))
 (Client certificate not present)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1488994193; bh=mvl2ZIDJYANlEWdddQp+HuyR9OzlJvMML2usxqe7tY4=;
 h=From:To:Subject:Date:Message-ID;
 b=ZsprDKVIBLJ9ymtHgLVMi2K3+G2Ji6Kuu3oUVilkloH53sMCnUCHlnWqDOmxU+i4y
 OHag0jMqBvWnXtkC/wlxR4f87ZbZ52v2YMpJzOcLGS0gDcg2yNY68/kkzzzJMaWtNc
 FNcRyXTrc4w3/gyoSej2Vry06SH6CtN+6/1zTj6M=
Authentication-Results: smtp2h.mail.yandex.net; dkim=pass header.i=@yandex.ru
X-Yandex-Suid-Status: 1 0
From: Arseny Sher <sher-ars@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 26.0.50; epatch for multifile patches
Date: Wed, 08 Mar 2017 20:29:52 +0300
Message-ID: <87varjfzhr.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 08 Mar 2017 12:33:10 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

Hello,

I am having trouble using epatch while applying multifile patches.
Consider the following simple example:

ars@ars-thinkpad ~/tmp $ mkdir -p old/src
ars@ars-thinkpad ~/tmp $ echo "void main() { }" > old/src/hello.c
ars@ars-thinkpad ~/tmp $ mkdir -p new/src
ars@ars-thinkpad ~/tmp $ echo "int main() { return 0; }" > new/src/hello.c
ars@ars-thinkpad ~/tmp $ diff -cr old/ new/ > tmp.patch
ars@ars-thinkpad ~/tmp $ cat tmp.patch
diff -cr old/src/hello.c new/src/hello.c
*** old/src/hello.c	2017-03-08 14:29:24.743846995 +0300
--- new/src/hello.c	2017-03-08 14:29:32.399846824 +0300
***************
*** 1 ****
! void main() { }
--- 1 ----
! int main() { return 0; }


Now I start emacs and do M-x epatch. First of all, it asks me for
patch buffer or file, I point to '~/tmp/tmp.patch'. Then it asks for
directory to patch, I say '~/tmp/old' and ediff complains

Ediff has inferred that
	/home/ars/tmp/old/hello.c
is assumed to be the target for this patch.  However, this file does not exist.

Please enter an alternative patch target ...


because it ignores the path ('src' directory in this case) to the file.
Ediff manual says: "Ediff can recognize multi-file patches only if they
are in the context format or GNU unified format. All other patches are
treated as 1-file patches. Ediff is [hopefully] using the same algorithm
as patch to determine which files need to be patched." If I understand
this correctly, my scenario should work, so it seems like a bug.

I tried it on GNU Emacs versions 25.1, 25.2 RC2 and daily build
26.0.50.2, sometimes on clean Emacs (emacs -q), and sometimes with
unified diff format (diff -u), the result is the same.

I use GNU/Linux, Linux Mint 17 (based on Ubuntu 14.04).

Below goes autogenerated info from report-emacs-bug.

In GNU Emacs 26.0.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8)
 of 2016-10-26 built on lgw01-50
Windowing system distributor 'The X.Org Foundation', version 11.0.11501000
System Description:	Linux Mint 17 Qiana

Recent messages:
my-misc loaded
Loading /home/ars/.emacs.d/recentf...done
Cleaning up the recentf list...done (0 removed)
my-text-processing loaded
Loading font-lock...done
my-windows-frames-funcs loaded
coding styles loaded
my-gdb-stuff loaded
Loading quail/cyrillic...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --build=x86_64-linux-gnu --prefix=/usr
 '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
 '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
 '--libdir=${prefix}/lib/x86_64-linux-gnu'
 '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
 --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
 --program-suffix=-snapshot --with-modules=yes --with-x=yes
 --with-x-toolkit=gtk3 --with-xwidgets=yes 'CFLAGS=-g -O2
 -fstack-protector --param=ssp-buffer-size=4 -Wformat
 -Werror=format-security' CPPFLAGS=-D_FORTIFY_SOURCE=2
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_MONETARY: ru_RU.UTF-8
  value of $LC_NUMERIC: ru_RU.UTF-8
  value of $LC_TIME: ru_RU.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  gud-tooltip-mode: t
  diff-hl-flydiff-mode: t
  global-diff-hl-mode: t
  diff-auto-refine-mode: t
  global-flycheck-mode: t
  projectile-mode: t
  ivy-mode: t
  show-paren-mode: t
  my-global-fci-mode: t
  global-linum-mode: t
  dired-omit-mode: t
  delete-selection-mode: t
  cua-mode: t
  recentf-mode: t
  savehist-mode: t
  global-undo-tree-mode: t
  global-auto-revert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
~/.emacs.d/static_packages/all-the-icons.el/all-the-icons hides ~/.emacs.d/static_packages/all-the-icons
/usr/share/emacs/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/26.0.50/lisp/textmodes/ispell
/usr/share/emacs/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/26.0.50/lisp/textmodes/flyspell
/usr/share/emacs/site-lisp/latex-cjk-thai/thai-word hides /usr/share/emacs/26.0.50/lisp/language/thai-word

Features:
(shadow sort mail-extr emacsbug message puny format-spec rfc822 mml
mml-sec epa derived epg gnus-util rmail rmail-loaddefs mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils colir
color ggtags etags xref project windmove quail gud my-gdb-stuff
diff-hl-flydiff diff-hl edmacro kmacro face-remap vc-hg vc-git vc-dir
ewoc vc vc-dispatcher diff-mode flycheck json map find-func rx subr-x
coding-styles cc-styles cc-align cc-engine cc-vars cc-defs projectile
advice grep compile comint ansi-color ibuf-ext ibuffer ibuffer-loaddefs
ivy ivy-overlay ffap thingatpt xcscope ring paren disp-table
fill-column-indicator easy-mmode linum dired-x dired dired-loaddefs
my-windows-frames-funcs all-the-icons all-the-icons-faces
data-weathericons data-octicons data-fileicons data-faicons
data-alltheicons font-lock+ cl dash my-text-processing drag-stuff delsel
cua-base recentf tree-widget wid-edit savehist undo-tree diff autorevert
filenotify wombat-theme my-misc finder-inf tex-site info package
epg-config url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache url-vars seq byte-opt gv bytecomp
byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev
obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face
macroexp files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
xwidget-internal move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 288745 21478)
 (symbols 48 35267 1)
 (miscs 40 517 1228)
 (strings 32 74748 9913)
 (string-bytes 1 2122820)
 (vectors 16 35442)
 (vector-slots 8 683178 9673)
 (floats 8 665 276)
 (intervals 56 444 300)
 (buffers 976 13)
 (heap 1024 41802 1607))




Acknowledgement sent to Arseny Sher <sher-ars@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#26028; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 24 May 2017 01:00:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.