]>
Commit | Line | Data |
---|---|---|
4c025c66 RP |
1 | #!/bin/sh |
2 | ||
3 | test_description='git apply of i-t-a file' | |
4 | ||
27472b51 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
4c025c66 RP |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success setup ' | |
9 | test_write_lines 1 2 3 4 5 >blueprint && | |
10 | ||
11 | cat blueprint >test-file && | |
12 | git add -N test-file && | |
13 | git diff >creation-patch && | |
14 | grep "new file mode 100644" creation-patch && | |
15 | ||
16 | rm -f test-file && | |
17 | git diff >deletion-patch && | |
18 | grep "deleted file mode 100644" deletion-patch | |
19 | ' | |
20 | ||
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 && | |
25 | ||
26 | git apply --cached creation-patch && | |
27 | git cat-file blob :test-file >actual && | |
28 | test_cmp blueprint actual | |
29 | ' | |
30 | ||
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 && | |
36 | ||
37 | test_must_fail git apply --index creation-patch | |
38 | ' | |
39 | ||
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 && | |
44 | ||
45 | git apply --cached deletion-patch && | |
46 | test_must_fail git ls-files --stage --error-unmatch test-file | |
47 | ' | |
48 | ||
49 | test_expect_success 'apply deletion patch to ita path (--index)' ' | |
50 | cat blueprint >test-file && | |
51 | git add -N test-file && | |
52 | ||
53 | test_must_fail git apply --index deletion-patch && | |
54 | git ls-files --stage --error-unmatch test-file | |
55 | ' | |
56 | ||
57 | test_done |