From: Mirko Faina <mroik@delayed.space>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Mirko Faina <mroik@delayed.space>
Subject: Re: [PATCH v2] apply.c: fix -p argument parsing
Date: Tue, 10 Mar 2026 05:45:04 +0100 [thread overview]
Message-ID: <aa-eXgsUnQRV7nvZ@exploit> (raw)
In-Reply-To: <xmqqwlzkxsv5.fsf@gitster.g>
On Mon, Mar 09, 2026 at 08:31:42PM -0700, Junio C Hamano wrote:
> Curious. It is true that we need to parse the p_value correctly
> even when we are applying a binary patch, but the problem is not
> limited to binary patches, is it?
Using a better regex I now realize t4120 would've been more apropriate.
I will move the tests.
> Is this saying "in the directory there must be only a single file
> whose name is t?" Wouldn't it be more readable and direct to do
> something like
>
> test_path_is_dir t
>
> or is there something more subtle going on here?
Sorry, this approach is due to the unfamiliarity of the testing
framework. I must've missed test_path_is_dir, the README is very dense
so trying to find things at a glance is not the easiest (in my opinion).
Will rewrite to use test_path_is_dir.
> > +test_expect_success 'git apply -p malformed patch' '
> > + test_must_fail git apply -p malformed $TEST_DIRECTORY/t4103/patch
> > +'
> >
> > +test_expect_success 'git apply -p 2q patch' '
> > + test_must_fail git apply -p 2q $TEST_DIRECTORY/t4103/patch
> > +'
>
> If this did not fail and patch gets applied with some p_value that
> happens to be used when we fail to parse the number, then ...
>
> > +test_expect_success 'git apply -p -1 patch' '
> > + test_must_fail git apply -p -1 $TEST_DIRECTORY/t4103/patch
> > +'
>
> ... it would not be clear why this step fails. Perhaps with that
> same "unable to parse" p_value was used and this tried to create the
> same file as the previous step already created, or we detected parse
> failure. We cannot tell.
>
> It probably is a good idea to prepare for the worst by doing
> something silly like
>
> test_when_finished "rm -f t/test/test test/test test" &&
>
> at the beginning of each of these tests so that we would clean up
> whatever we could leave behind? I dunno.
right, "rm -rf t test" should be enough, will add this cleanup code.
Thank you for the review :)
next prev parent reply other threads:[~2026-03-10 4:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 23:26 [PATCH] apply.c: fix -p argument parsing Mirko Faina
2026-03-09 23:43 ` Junio C Hamano
2026-03-10 0:54 ` [PATCH v2] " Mirko Faina
2026-03-10 3:31 ` Junio C Hamano
2026-03-10 4:45 ` Mirko Faina [this message]
2026-03-10 5:06 ` [PATCH v3] " Mirko Faina
2026-03-10 13:13 ` Junio C Hamano
2026-03-13 0:16 ` Jeff King
2026-03-13 1:12 ` Jeff King
2026-03-13 1:29 ` Jeff King
2026-03-13 4:27 ` Junio C Hamano
2026-03-13 4:19 ` Junio C Hamano
2026-03-13 3:19 ` [PATCH v4] " Mirko Faina
2026-03-13 4:39 ` Junio C Hamano
2026-03-16 0:51 ` [PATCH] " Mirko Faina
2026-03-16 0:52 ` Mirko Faina
2026-03-16 19:56 ` Junio C Hamano
2026-03-15 17:22 ` Tian Yuchen
2026-03-15 17:56 ` Mirko Faina
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=aa-eXgsUnQRV7nvZ@exploit \
--to=mroik@delayed.space \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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