3 test_description
='apply empty'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success setup
'
12 git commit -m initial &&
13 git commit --allow-empty -m "empty commit" &&
14 git format-patch --always HEAD~ >empty.patch &&
15 test_write_lines a b c d e >empty &&
18 sed -e "/^diff --git/d" \
20 -e "s|a/empty|empty.orig|" \
21 -e "s|b/empty|empty|" >patch0 &&
22 sed -e "s|empty|missing|" patch0 >patch1 &&
24 git update-index --refresh
27 test_expect_success
'apply empty' '
29 test_when_finished "git reset --hard" &&
34 test_expect_success
'apply empty patch fails' '
35 test_when_finished "git reset --hard" &&
36 test_must_fail git apply empty.patch &&
37 test_must_fail git apply - </dev/null
40 test_expect_success
'apply with --allow-empty succeeds' '
41 test_when_finished "git reset --hard" &&
42 git apply --allow-empty empty.patch &&
43 git apply --allow-empty - </dev/null
46 test_expect_success
'apply --index empty' '
48 test_when_finished "git reset --hard" &&
49 git apply --index patch0 &&
50 test_cmp expect empty &&
54 test_expect_success
'apply create' '
56 test_when_finished "git reset --hard" &&
58 test_cmp expect missing
61 test_expect_success
'apply --index create' '
63 test_when_finished "git reset --hard" &&
64 git apply --index patch1 &&
65 test_cmp expect missing &&
69 test_expect_success
!MINGW
'apply with no-contents and a funny pathname' '
70 test_when_finished "rm -fr \"funny \"; git reset --hard" &&
74 git add "funny /empty" &&
75 git diff HEAD -- "funny /" >sample.patch &&
76 git diff -R HEAD -- "funny /" >elpmas.patch &&
80 git apply --stat --check --apply sample.patch &&
81 test_must_be_empty "funny /empty" &&
83 git apply --stat --check --apply elpmas.patch &&
84 test_path_is_missing "funny /empty" &&
86 git apply -R --stat --check --apply elpmas.patch &&
87 test_must_be_empty "funny /empty" &&
89 git apply -R --stat --check --apply sample.patch &&
90 test_path_is_missing "funny /empty"