summaryrefslogtreecommitdiff
path: root/t/t4140-apply-ita.sh
diff options
context:
space:
mode:
authorRaymond E. Pasco <ray@ameretat.dev>2020-08-08 07:49:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-08-09 18:00:46 (GMT)
commit4c025c667ee29dd5e9260f423e8b0b3cc37e5e8c (patch)
tree674331549921085aebc6cbe72617b41d288f7458 /t/t4140-apply-ita.sh
parente3cc41b4f939a64c74b6d4a2d59f6efe006c4e4b (diff)
downloadgit-4c025c667ee29dd5e9260f423e8b0b3cc37e5e8c.zip
git-4c025c667ee29dd5e9260f423e8b0b3cc37e5e8c.tar.gz
git-4c025c667ee29dd5e9260f423e8b0b3cc37e5e8c.tar.bz2
t4140: test apply with i-t-a paths
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4140-apply-ita.sh')
-rwxr-xr-xt/t4140-apply-ita.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh
new file mode 100755
index 0000000..c614eaf
--- /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_expect_success 'apply creation patch to ita path (--cached)' '
+ git rm -f test-file &&
+ cat blueprint >test-file &&
+ git add -N test-file &&
+
+ 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 &&
+ 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