Merge branch 'ms/rebase-insnformat-doc-fix' into maint-2.43
[git.git] / t / t4140-apply-ita.sh
blobb375aca0d74ea3a23e6eae69077e9b286b5c144f
1 #!/bin/sh
3 test_description='git apply of i-t-a file'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success setup '
9 test_write_lines 1 2 3 4 5 >blueprint &&
11 cat blueprint >test-file &&
12 git add -N test-file &&
13 git diff >creation-patch &&
14 grep "new file mode 100644" creation-patch &&
16 rm -f test-file &&
17 git diff >deletion-patch &&
18 grep "deleted file mode 100644" deletion-patch
21 test_expect_success 'apply creation patch to ita path (--cached)' '
22 git rm -f test-file &&
23 cat blueprint >test-file &&
24 git add -N test-file &&
26 git apply --cached creation-patch &&
27 git cat-file blob :test-file >actual &&
28 test_cmp blueprint actual
31 test_expect_success 'apply creation patch to ita path (--index)' '
32 git rm -f test-file &&
33 cat blueprint >test-file &&
34 git add -N test-file &&
35 rm -f test-file &&
37 test_must_fail git apply --index creation-patch
40 test_expect_success 'apply deletion patch to ita path (--cached)' '
41 git rm -f test-file &&
42 cat blueprint >test-file &&
43 git add -N test-file &&
45 git apply --cached deletion-patch &&
46 test_must_fail git ls-files --stage --error-unmatch test-file
49 test_expect_success 'apply deletion patch to ita path (--index)' '
50 cat blueprint >test-file &&
51 git add -N test-file &&
53 test_must_fail git apply --index deletion-patch &&
54 git ls-files --stage --error-unmatch test-file
57 test_done