t4129: don't fail if setgid is set in the test directory
[git] / t / t4140-apply-ita.sh
1 #!/bin/sh
2
3 test_description='git apply of i-t-a file'
4
5 . ./test-lib.sh
6
7 test_expect_success setup '
8         test_write_lines 1 2 3 4 5 >blueprint &&
9
10         cat blueprint >test-file &&
11         git add -N test-file &&
12         git diff >creation-patch &&
13         grep "new file mode 100644" creation-patch &&
14
15         rm -f test-file &&
16         git diff >deletion-patch &&
17         grep "deleted file mode 100644" deletion-patch
18 '
19
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 &&
24
25         git apply --cached creation-patch &&
26         git cat-file blob :test-file >actual &&
27         test_cmp blueprint actual
28 '
29
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 &&
35
36         test_must_fail git apply --index creation-patch
37 '
38
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 &&
43
44         git apply --cached deletion-patch &&
45         test_must_fail git ls-files --stage --error-unmatch test-file
46 '
47
48 test_expect_success 'apply deletion patch to ita path (--index)' '
49         cat blueprint >test-file &&
50         git add -N test-file &&
51
52         test_must_fail git apply --index deletion-patch &&
53         git ls-files --stage --error-unmatch test-file
54 '
55
56 test_done