From: Junio C Hamano <gitster@pobox.com>
To: Federico Cuello <fedux@lugmen.org.ar>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Fix git-apply with -p greater than 1
Date: Thu, 21 Oct 2010 22:01:20 -0700 [thread overview]
Message-ID: <7viq0urfbz.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1287699122-26702-1-git-send-email-fedux@lugmen.org.ar> (Federico Cuello's message of "Thu\, 21 Oct 2010 19\:12\:02 -0300")
Federico Cuello <fedux@lugmen.org.ar> writes:
> Fix the case when the patch is a rename or mode-change only
> and -p is used with a value greater than one.
> The git_header_name function did not remove more than one path
> component.
>
> Signed-off-by: Federico Cuello <fedux@lugmen.org.ar>
Thanks.
It is customary to protect your fix with additional test script so that
you do not have to be constantly monitoring the mailing list traffic to
make sure somebody else will not break your changes.
Perhaps something like this? Note that I didn't run the test myself,
though (for that matter, I haven't applied your patch to see if it
compiles, yet).
t/t4120-apply-popt.sh | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh
index 2b2d00b..579c9e6 100755
--- a/t/t4120-apply-popt.sh
+++ b/t/t4120-apply-popt.sh
@@ -56,4 +56,30 @@ test_expect_success 'apply with too large -p and fancy filename' '
grep "removing 3 leading" err
'
+test_expect_success 'apply (-p2) diff, mode change only' '
+ cat >patch.chmod <<-\EOF &&
+ diff --git a/sub/file1 b/sub/file1
+ old mode 100644
+ new mode 100755
+ EOF
+ chmod 644 file1 &&
+ git apply -p2 patch.chmod &&
+ test -x file1
+'
+
+test_expect_success 'apply (-p2) diff, rename' '
+ cat >patch.rename <<-\EOF &&
+ diff --git a/sub/file1 b/sub/file2
+ similarity index 100%
+ rename from sub/file1
+ rename to sub/file2
+ EOF
+ echo A >expected &&
+
+ cp file1.saved file1 &&
+ rm -f file2 &&
+ git apply -p2 patch.rename &&
+ test_cmp expected file2
+'
+
test_done
next prev parent reply other threads:[~2010-10-22 5:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-21 22:12 [PATCH] Fix git-apply with -p greater than 1 Federico Cuello
2010-10-22 5:01 ` Junio C Hamano [this message]
2010-10-22 5:31 ` Jonathan Nieder
2010-10-22 13:42 ` Fede
2010-10-22 15:38 ` Jonathan Nieder
2010-10-22 18:41 ` Junio C Hamano
2010-10-22 18:51 ` Federico Cuello
2010-10-25 14:11 ` Federico Cuello
2010-10-22 18:40 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7viq0urfbz.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=fedux@lugmen.org.ar \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).