Merge branch 'rs/daemon-sanitize-dir-sep'
[git.git] / t / t4140-apply-ita.sh
blobc614eaf04cca93a22157d08e9fc464639468eb3a
1 #!/bin/sh
3 test_description='git apply of i-t-a file'
5 . ./test-lib.sh
7 test_expect_success setup '
8 test_write_lines 1 2 3 4 5 >blueprint &&
10 cat blueprint >test-file &&
11 git add -N test-file &&
12 git diff >creation-patch &&
13 grep "new file mode 100644" creation-patch &&
15 rm -f test-file &&
16 git diff >deletion-patch &&
17 grep "deleted file mode 100644" deletion-patch
20 test_expect_success 'apply creation patch to ita path (--cached)' '
21 git rm -f test-file &&
22 cat blueprint >test-file &&
23 git add -N test-file &&
25 git apply --cached creation-patch &&
26 git cat-file blob :test-file >actual &&
27 test_cmp blueprint actual
30 test_expect_success 'apply creation patch to ita path (--index)' '
31 git rm -f test-file &&
32 cat blueprint >test-file &&
33 git add -N test-file &&
34 rm -f test-file &&
36 test_must_fail git apply --index creation-patch
39 test_expect_success 'apply deletion patch to ita path (--cached)' '
40 git rm -f test-file &&
41 cat blueprint >test-file &&
42 git add -N test-file &&
44 git apply --cached deletion-patch &&
45 test_must_fail git ls-files --stage --error-unmatch test-file
48 test_expect_success 'apply deletion patch to ita path (--index)' '
49 cat blueprint >test-file &&
50 git add -N test-file &&
52 test_must_fail git apply --index deletion-patch &&
53 git ls-files --stage --error-unmatch test-file
56 test_done