Re: [PATCH v5 3/3] t4140: test apply with i-t-a paths
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Aug 23, 2020, 15:58 UTC
- Message-ID
- <c5ee08e9-572e-b77d-ee69-f07cf79651c6@gmail.com>
- In-Reply-To
- <20200808074959.35943-4-ray@ameretat.dev>
Hi Raymond
On 08/08/2020 08:49, Raymond E. Pasco wrote:
Show 35 quoted lines
> apply --cached (as used by add -p) should accept creation and deletion > patches to intent-to-add paths in the index. apply --index, however, > should always fail because an intent-to-add path never matches the > worktree (by definition). > > Based-on-patch-by: Junio C Hamano <gitster@pobox.com> > Signed-off-by: Raymond E. Pasco <ray@ameretat.dev> > --- > t/t4140-apply-ita.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 56 insertions(+) > create mode 100755 t/t4140-apply-ita.sh > > diff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh > new file mode 100755 > index 0000000000..c614eaf04c > --- /dev/null > +++ b/t/t4140-apply-ita.sh > @@ -0,0 +1,56 @@ > +#!/bin/sh > + > +test_description='git apply of i-t-a file' > + > +. ./test-lib.sh > + > +test_expect_success setup ' > + test_write_lines 1 2 3 4 5 >blueprint && > + > + cat blueprint >test-file && > + git add -N test-file && > + git diff >creation-patch && > + grep "new file mode 100644" creation-patch && > + > + rm -f test-file && > + git diff >deletion-patch && > + grep "deleted file mode 100644" deletion-patch
test-file is still i-t-a in the index ...
Show 6 quoted lines
> +' > + > +test_expect_success 'apply creation patch to ita path (--cached)' ' > + git rm -f test-file && > + cat blueprint >test-file && > + git add -N test-file &&
so 'add -N' does nothing ...
Show 10 quoted lines
> + > + git apply --cached creation-patch && > + git cat-file blob :test-file >actual && > + test_cmp blueprint actual > +' > + > +test_expect_success 'apply creation patch to ita path (--index)' ' > + git rm -f test-file && > + cat blueprint >test-file && > + git add -N test-file &&
If the last test was successful then test-file is already in the index and 'add -N' has no effect, 'apply --index' will fail wether or not it rejects i-t-a entries.
I think you should fix this by adding
test_when_finished git read-tree --empty
(or possibly 'git reset' if that works correctly when HEAD is invalid) to each test in this file
Best Wishes
Phillip
Show 23 quoted lines
> + rm -f test-file && > + test_must_fail git apply --index creation-patch > +' > + > +test_expect_success 'apply deletion patch to ita path (--cached)' ' > + git rm -f test-file && > + cat blueprint >test-file && > + git add -N test-file && > + > + git apply --cached deletion-patch && > + test_must_fail git ls-files --stage --error-unmatch test-file > +' > + > +test_expect_success 'apply deletion patch to ita path (--index)' ' > + cat blueprint >test-file && > + git add -N test-file && > + > + test_must_fail git apply --index deletion-patch && > + git ls-files --stage --error-unmatch test-file > +' > + > +test_done >