fsmonitor--daemon: don't translate literal commands
[git/debian.git] / t / t4126-apply-empty.sh
blob33860d3829085211d5a5aa4da9468fa52cae4d9b
1 #!/bin/sh
3 test_description='apply empty'
6 TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
9 test_expect_success setup '
10 >empty &&
11 git add empty &&
12 test_tick &&
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 &&
17 cat empty >expect &&
18 git diff |
19 sed -e "/^diff --git/d" \
20 -e "/^index /d" \
21 -e "s|a/empty|empty.orig|" \
22 -e "s|b/empty|empty|" >patch0 &&
23 sed -e "s|empty|missing|" patch0 >patch1 &&
24 >empty &&
25 git update-index --refresh
28 test_expect_success 'apply empty' '
29 rm -f missing &&
30 test_when_finished "git reset --hard" &&
31 git apply patch0 &&
32 test_cmp expect empty
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' '
48 rm -f missing &&
49 test_when_finished "git reset --hard" &&
50 git apply --index patch0 &&
51 test_cmp expect empty &&
52 git diff --exit-code
55 test_expect_success 'apply create' '
56 rm -f missing &&
57 test_when_finished "git reset --hard" &&
58 git apply patch1 &&
59 test_cmp expect missing
62 test_expect_success 'apply --index create' '
63 rm -f missing &&
64 test_when_finished "git reset --hard" &&
65 git apply --index patch1 &&
66 test_cmp expect missing &&
67 git diff --exit-code
70 test_done