3 test_description
='apply empty'
6 TEST_PASSES_SANITIZE_LEAK
=true
9 test_expect_success setup
'
13 git commit -m initial &&
14 git commit --allow-empty -m "empty commit" &&
15 git format-patch --always HEAD~ >empty.patch &&
16 test_write_lines a b c d e >empty &&
19 sed -e "/^diff --git/d" \
21 -e "s|a/empty|empty.orig|" \
22 -e "s|b/empty|empty|" >patch0 &&
23 sed -e "s|empty|missing|" patch0 >patch1 &&
25 git update-index --refresh
28 test_expect_success
'apply empty' '
30 test_when_finished "git reset --hard" &&
35 test_expect_success
'apply empty patch fails' '
36 test_when_finished "git reset --hard" &&
37 test_must_fail git apply empty.patch &&
38 test_must_fail git apply - </dev/null
41 test_expect_success
'apply with --allow-empty succeeds' '
42 test_when_finished "git reset --hard" &&
43 git apply --allow-empty empty.patch &&
44 git apply --allow-empty - </dev/null
47 test_expect_success
'apply --index empty' '
49 test_when_finished "git reset --hard" &&
50 git apply --index patch0 &&
51 test_cmp expect empty &&
55 test_expect_success
'apply create' '
57 test_when_finished "git reset --hard" &&
59 test_cmp expect missing
62 test_expect_success
'apply --index create' '
64 test_when_finished "git reset --hard" &&
65 git apply --index patch1 &&
66 test_cmp expect missing &&