3 test_description
='errors in upload-pack'
5 TEST_PASSES_SANITIZE_LEAK
=true
11 object_sha1
=$
(git rev-parse
"$1") &&
12 ob
=$
(expr "$object_sha1" : "\(..\)") &&
13 ject
=$
(expr "$object_sha1" : "..\(..*\)") &&
14 rm -f ".git/objects/$ob/$ject"
17 test_expect_success
'setup and corrupt repository' '
20 git rev-parse :file &&
21 git commit -a -m original &&
24 git commit -a -m changed &&
25 corrupt_repo HEAD:file
29 test_expect_success
'fsck fails' '
30 test_must_fail git fsck
33 test_expect_success
'upload-pack fails due to error in pack-objects packing' '
34 head=$(git rev-parse HEAD) &&
35 hexsz=$(test_oid hexsz) &&
36 printf "%04xwant %s\n00000009done\n0000" \
37 $(($hexsz + 10)) $head >input &&
38 test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
39 test_grep "unable to read" output.err &&
40 test_grep "pack-objects died" output.err
43 test_expect_success
'corrupt repo differently' '
45 git hash-object -w file &&
46 corrupt_repo HEAD^^{tree}
50 test_expect_success
'fsck fails' '
51 test_must_fail git fsck
53 test_expect_success
'upload-pack fails due to error in rev-list' '
55 printf "%04xwant %s\n%04xshallow %s00000009done\n0000" \
56 $(($hexsz + 10)) $(git rev-parse HEAD) \
57 $(($hexsz + 12)) $(git rev-parse HEAD^) >input &&
58 test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
59 grep "bad tree object" output.err
62 test_expect_success
'upload-pack fails due to bad want (no object)' '
64 printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \
65 $(($hexsz + 29)) $(test_oid deadbeef) >input &&
66 test_must_fail git upload-pack . <input >output 2>output.err &&
67 grep "not our ref" output.err &&
69 ! grep multi_ack_detailed output.err
72 test_expect_success
'upload-pack fails due to bad want (not tip)' '
74 oid=$(echo an object we have | git hash-object -w --stdin) &&
75 printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \
76 $(($hexsz + 29)) "$oid" >input &&
77 test_must_fail git upload-pack . <input >output 2>output.err &&
78 grep "not our ref" output.err &&
80 ! grep multi_ack_detailed output.err
83 test_expect_success
'upload-pack fails due to error in pack-objects enumeration' '
85 printf "%04xwant %s\n00000009done\n0000" \
86 $((hexsz + 10)) $(git rev-parse HEAD) >input &&
87 test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
88 grep "bad tree object" output.err &&
89 grep "pack-objects died" output.err
92 test_expect_success
'upload-pack tolerates EOF just after stateless client wants' '
93 test_commit initial &&
94 head=$(git rev-parse HEAD) &&
97 packetize "want $head" &&
98 packetize "shallow $head" &&
99 packetize "deepen 1" &&
103 printf "0000" >expect &&
105 git upload-pack --stateless-rpc . <request >actual &&
106 test_cmp expect actual
109 test_expect_success
'create empty repository' '
117 test_expect_success
'fetch fails' '
119 test_must_fail git fetch .. main