]>
Commit | Line | Data |
---|---|---|
4c324c00 JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='errors in upload-pack' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
14dc2d98 | 7 | D=$(pwd) |
4c324c00 JS |
8 | |
9 | corrupt_repo () { | |
10 | object_sha1=$(git rev-parse "$1") && | |
11 | ob=$(expr "$object_sha1" : "\(..\)") && | |
12 | ject=$(expr "$object_sha1" : "..\(..*\)") && | |
13 | rm -f ".git/objects/$ob/$ject" | |
14 | } | |
15 | ||
16 | test_expect_success 'setup and corrupt repository' ' | |
83207221 | 17 | test_oid_init && |
4c324c00 JS |
18 | echo file >file && |
19 | git add file && | |
20 | git rev-parse :file && | |
21 | git commit -a -m original && | |
22 | test_tick && | |
23 | echo changed >file && | |
24 | git commit -a -m changed && | |
25 | corrupt_repo HEAD:file | |
26 | ||
27 | ' | |
28 | ||
41ac414e | 29 | test_expect_success 'fsck fails' ' |
d492b31c | 30 | test_must_fail git fsck |
4c324c00 JS |
31 | ' |
32 | ||
f0cea83f | 33 | test_expect_success 'upload-pack fails due to error in pack-objects packing' ' |
83207221 | 34 | head=$(git rev-parse HEAD) && |
35 | hexsz=$(test_oid hexsz) && | |
36 | printf "%04xwant %s\n00000009done\n0000" \ | |
37 | $(($hexsz + 10)) $head >input && | |
1d8cd418 | 38 | test_must_fail git upload-pack . <input >/dev/null 2>output.err && |
9aa98efc JX |
39 | test_i18ngrep "unable to read" output.err && |
40 | test_i18ngrep "pack-objects died" output.err | |
4c324c00 JS |
41 | ' |
42 | ||
43 | test_expect_success 'corrupt repo differently' ' | |
44 | ||
45 | git hash-object -w file && | |
46 | corrupt_repo HEAD^^{tree} | |
47 | ||
48 | ' | |
49 | ||
41ac414e | 50 | test_expect_success 'fsck fails' ' |
d492b31c | 51 | test_must_fail git fsck |
4c324c00 JS |
52 | ' |
53 | test_expect_success 'upload-pack fails due to error in rev-list' ' | |
54 | ||
83207221 | 55 | printf "%04xwant %s\n%04xshallow %s00000009done\n0000" \ |
56 | $(($hexsz + 10)) $(git rev-parse HEAD) \ | |
57 | $(($hexsz + 12)) $(git rev-parse HEAD^) >input && | |
1d8cd418 | 58 | test_must_fail git upload-pack . <input >/dev/null 2>output.err && |
0ac77ec3 | 59 | grep "bad tree object" output.err |
4c324c00 JS |
60 | ' |
61 | ||
014ade74 | 62 | test_expect_success 'upload-pack fails due to bad want (no object)' ' |
9f9aa761 | 63 | |
83207221 | 64 | printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \ |
65 | $(($hexsz + 29)) $(test_oid deadbeef) >input && | |
9f9aa761 | 66 | test_must_fail git upload-pack . <input >output 2>output.err && |
6963a4e4 JK |
67 | grep "not our ref" output.err && |
68 | grep "ERR" output && | |
69 | ! grep multi_ack_detailed output.err | |
9f9aa761 EN |
70 | ' |
71 | ||
014ade74 JK |
72 | test_expect_success 'upload-pack fails due to bad want (not tip)' ' |
73 | ||
74 | oid=$(echo an object we have | git hash-object -w --stdin) && | |
83207221 | 75 | printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \ |
76 | $(($hexsz + 29)) "$oid" >input && | |
014ade74 JK |
77 | test_must_fail git upload-pack . <input >output 2>output.err && |
78 | grep "not our ref" output.err && | |
79 | grep "ERR" output && | |
80 | ! grep multi_ack_detailed output.err | |
81 | ' | |
82 | ||
f0cea83f NE |
83 | test_expect_success 'upload-pack fails due to error in pack-objects enumeration' ' |
84 | ||
83207221 | 85 | printf "%04xwant %s\n00000009done\n0000" \ |
86 | $((hexsz + 10)) $(git rev-parse HEAD) >input && | |
1d8cd418 | 87 | test_must_fail git upload-pack . <input >/dev/null 2>output.err && |
f0cea83f NE |
88 | grep "bad tree object" output.err && |
89 | grep "pack-objects died" output.err | |
90 | ' | |
91 | ||
4c324c00 JS |
92 | test_expect_success 'create empty repository' ' |
93 | ||
94 | mkdir foo && | |
95 | cd foo && | |
96 | git init | |
97 | ||
98 | ' | |
99 | ||
41ac414e | 100 | test_expect_success 'fetch fails' ' |
4c324c00 | 101 | |
d492b31c | 102 | test_must_fail git fetch .. master |
4c324c00 JS |
103 | |
104 | ' | |
105 | ||
106 | test_done |