3 test_description
='errors in upload-pack'
10 object_sha1
=$
(git rev-parse
"$1") &&
11 ob
=$
(expr "$object_sha1" : "\(..\)") &&
12 ject
=$
(expr "$object_sha1" : "..\(..*\)") &&
13 rm -f ".git/objects/$ob/$ject"
16 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' '
35 printf "0032want %s\n00000009done\n0000" \
36 $(git rev-parse HEAD) >input &&
37 test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
38 test_i18ngrep "unable to read" output.err &&
39 test_i18ngrep "pack-objects died" output.err
42 test_expect_success
'corrupt repo differently' '
44 git hash-object -w file &&
45 corrupt_repo HEAD^^{tree}
49 test_expect_success
'fsck fails' '
50 test_must_fail git fsck
52 test_expect_success
'upload-pack fails due to error in rev-list' '
54 printf "0032want %s\n0034shallow %s00000009done\n0000" \
55 $(git rev-parse HEAD) $(git rev-parse HEAD^) >input &&
56 test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
57 # pack-objects survived
58 grep "Total.*, reused" output.err &&
59 # but there was an error, which must have been in rev-list
60 grep "bad tree object" output.err
63 test_expect_success
'upload-pack error message when bad ref requested' '
65 printf "0045want %s multi_ack_detailed\n00000009done\n0000" \
66 "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" >input &&
67 test_must_fail git upload-pack . <input >output 2>output.err &&
68 grep -q "not our ref" output.err &&
69 ! grep -q multi_ack_detailed output.err
72 test_expect_success
'upload-pack fails due to error in pack-objects enumeration' '
74 printf "0032want %s\n00000009done\n0000" \
75 $(git rev-parse HEAD) >input &&
76 test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
77 grep "bad tree object" output.err &&
78 grep "pack-objects died" output.err
81 test_expect_success
'create empty repository' '
89 test_expect_success
'fetch fails' '
91 test_must_fail git fetch .. master