From: Junio C Hamano Date: Fri, 13 Mar 2026 04:39:47 GMT Subject: Re: [PATCH v4] apply.c: fix -p argument parsing Message-ID: In-Reply-To: <20260313031950.1695103-1-mroik@delayed.space> Mirko Faina writes: > As Jeff pointed out, the previous patch doesn't pass tests on windows... > Inlined as a workaround and to avoid adding additional folders to the > existing test directory. Thanks for working very well together. > +test_expect_success 'git apply -p 1 patch' ' > + cat >patch <<-\EOF && > + From 90ad11d5b2d437e82d4d992f72fb44c2227798b5 Mon Sep 17 00:00:00 2001 > + From: Mroik > + Date: Mon, 9 Mar 2026 23:25:00 +0100 > + Subject: [PATCH] Test > + > + --- > + t/test/test | 0 > + 1 file changed, 0 insertions(+), 0 deletions(-) > + create mode 100644 t/test/test > + > + diff --git a/t/test/test b/t/test/test > + new file mode 100644 > + index 0000000000..e69de29bb2 > + -- > + 2.53.0.851.ga537e3e6e9 > + > + EOF It is more customary to indent the here-doc body to the same level as surrounding < + test_when_finished "rm -rf t" && > + git apply -p 1 patch && > + test_path_is_dir t > +' > + > +test_expect_success 'apply fails due to non-num -p' ' > + test_when_finished "rm -rf t test" && > + test_must_fail git apply -p malformed patch > +' > + > +test_expect_success 'apply fails due to trailing non-digit in -p' ' > + test_when_finished "rm -rf t test" && > + test_must_fail git apply -p 2q patch > +' > + > +test_expect_success 'apply fails due to negative number in -p' ' > + test_when_finished "rm -rf t test patch" && > + test_must_fail git apply -p -1 patch > +' The test all make sense, but if we know what error message we are expecting, it may not be a bad idea to do something like test_must_fail git apply -p -1 patch 2>err && test_grep " has to be a non-negative" err to ensure that the command did not fail for a wrong reason. THanks.