block-sha1: improve code on large-register-set machines
[git/dscho.git] / t / t3800-mktag.sh
blob6fb027ba57eeb328ac48ec78ff5f685fd94a6f4b
1 #!/bin/sh
5 test_description='git mktag: tag object verify test'
7 . ./test-lib.sh
9 ###########################################################
10 # check the tag.sig file, expecting verify_tag() to fail,
11 # and checking that the error message matches the pattern
12 # given in the expect.pat file.
14 check_verify_failure () {
15 expect="$2"
16 test_expect_success "$1" '
17 ( test_must_fail git mktag <tag.sig 2>message ) &&
18 grep "$expect" message
22 ###########################################################
23 # first create a commit, so we have a valid object/type
24 # for the tag.
25 echo Hello >A
26 git update-index --add A
27 git commit -m "Initial commit"
28 head=$(git rev-parse --verify HEAD)
30 ############################################################
31 # 1. length check
33 cat >tag.sig <<EOF
34 too short for a tag
35 EOF
37 check_verify_failure 'Tag object length check' \
38 '^error: .*size wrong.*$'
40 ############################################################
41 # 2. object line label check
43 cat >tag.sig <<EOF
44 xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895
45 type tag
46 tag mytag
47 tagger . <> 0 +0000
49 EOF
51 check_verify_failure '"object" line label check' '^error: char0: .*"object "$'
53 ############################################################
54 # 3. object line SHA1 check
56 cat >tag.sig <<EOF
57 object zz9e9b33986b1c2670fff52c5067603117b3e895
58 type tag
59 tag mytag
60 tagger . <> 0 +0000
62 EOF
64 check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$'
66 ############################################################
67 # 4. type line label check
69 cat >tag.sig <<EOF
70 object 779e9b33986b1c2670fff52c5067603117b3e895
71 xxxx tag
72 tag mytag
73 tagger . <> 0 +0000
75 EOF
77 check_verify_failure '"type" line label check' '^error: char47: .*"\\ntype "$'
79 ############################################################
80 # 5. type line eol check
82 echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
83 printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
85 check_verify_failure '"type" line eol check' '^error: char48: .*"\\n"$'
87 ############################################################
88 # 6. tag line label check #1
90 cat >tag.sig <<EOF
91 object 779e9b33986b1c2670fff52c5067603117b3e895
92 type tag
93 xxx mytag
94 tagger . <> 0 +0000
96 EOF
98 check_verify_failure '"tag" line label check #1' \
99 '^error: char57: no "tag " found$'
101 ############################################################
102 # 7. tag line label check #2
104 cat >tag.sig <<EOF
105 object 779e9b33986b1c2670fff52c5067603117b3e895
106 type taggggggggggggggggggggggggggggggg
110 check_verify_failure '"tag" line label check #2' \
111 '^error: char87: no "tag " found$'
113 ############################################################
114 # 8. type line type-name length check
116 cat >tag.sig <<EOF
117 object 779e9b33986b1c2670fff52c5067603117b3e895
118 type taggggggggggggggggggggggggggggggg
119 tag mytag
122 check_verify_failure '"type" line type-name length check' \
123 '^error: char53: type too long$'
125 ############################################################
126 # 9. verify object (SHA1/type) check
128 cat >tag.sig <<EOF
129 object 779e9b33986b1c2670fff52c5067603117b3e895
130 type tagggg
131 tag mytag
132 tagger . <> 0 +0000
136 check_verify_failure 'verify object (SHA1/type) check' \
137 '^error: char7: could not verify object.*$'
139 ############################################################
140 # 10. verify tag-name check
142 cat >tag.sig <<EOF
143 object $head
144 type commit
145 tag my tag
146 tagger . <> 0 +0000
150 check_verify_failure 'verify tag-name check' \
151 '^error: char67: could not verify tag name$'
153 ############################################################
154 # 11. tagger line label check #1
156 cat >tag.sig <<EOF
157 object $head
158 type commit
159 tag mytag
161 This is filler
164 check_verify_failure '"tagger" line label check #1' \
165 '^error: char70: could not find "tagger "$'
167 ############################################################
168 # 12. tagger line label check #2
170 cat >tag.sig <<EOF
171 object $head
172 type commit
173 tag mytag
174 tagger
176 This is filler
179 check_verify_failure '"tagger" line label check #2' \
180 '^error: char70: could not find "tagger "$'
182 ############################################################
183 # 13. disallow missing tag author name
185 cat >tag.sig <<EOF
186 object $head
187 type commit
188 tag mytag
189 tagger <> 0 +0000
191 This is filler
194 check_verify_failure 'disallow missing tag author name' \
195 '^error: char77: missing tagger name$'
197 ############################################################
198 # 14. disallow missing tag author name
200 cat >tag.sig <<EOF
201 object $head
202 type commit
203 tag mytag
204 tagger T A Gger <
205 > 0 +0000
209 check_verify_failure 'disallow malformed tagger' \
210 '^error: char77: malformed tagger field$'
212 ############################################################
213 # 15. allow empty tag email
215 cat >tag.sig <<EOF
216 object $head
217 type commit
218 tag mytag
219 tagger T A Gger <> 0 +0000
223 test_expect_success \
224 'allow empty tag email' \
225 'git mktag <tag.sig >.git/refs/tags/mytag 2>message'
227 ############################################################
228 # 16. disallow spaces in tag email
230 cat >tag.sig <<EOF
231 object $head
232 type commit
233 tag mytag
234 tagger T A Gger <tag ger@example.com> 0 +0000
238 check_verify_failure 'disallow spaces in tag email' \
239 '^error: char77: malformed tagger field$'
241 ############################################################
242 # 17. disallow missing tag timestamp
244 tr '_' ' ' >tag.sig <<EOF
245 object $head
246 type commit
247 tag mytag
248 tagger T A Gger <tagger@example.com>__
252 check_verify_failure 'disallow missing tag timestamp' \
253 '^error: char107: missing tag timestamp$'
255 ############################################################
256 # 18. detect invalid tag timestamp1
258 cat >tag.sig <<EOF
259 object $head
260 type commit
261 tag mytag
262 tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008
266 check_verify_failure 'detect invalid tag timestamp1' \
267 '^error: char107: missing tag timestamp$'
269 ############################################################
270 # 19. detect invalid tag timestamp2
272 cat >tag.sig <<EOF
273 object $head
274 type commit
275 tag mytag
276 tagger T A Gger <tagger@example.com> 2008-03-31T12:20:15-0500
280 check_verify_failure 'detect invalid tag timestamp2' \
281 '^error: char111: malformed tag timestamp$'
283 ############################################################
284 # 20. detect invalid tag timezone1
286 cat >tag.sig <<EOF
287 object $head
288 type commit
289 tag mytag
290 tagger T A Gger <tagger@example.com> 1206478233 GMT
294 check_verify_failure 'detect invalid tag timezone1' \
295 '^error: char118: malformed tag timezone$'
297 ############################################################
298 # 21. detect invalid tag timezone2
300 cat >tag.sig <<EOF
301 object $head
302 type commit
303 tag mytag
304 tagger T A Gger <tagger@example.com> 1206478233 + 30
308 check_verify_failure 'detect invalid tag timezone2' \
309 '^error: char118: malformed tag timezone$'
311 ############################################################
312 # 22. detect invalid tag timezone3
314 cat >tag.sig <<EOF
315 object $head
316 type commit
317 tag mytag
318 tagger T A Gger <tagger@example.com> 1206478233 -1430
322 check_verify_failure 'detect invalid tag timezone3' \
323 '^error: char118: malformed tag timezone$'
325 ############################################################
326 # 23. detect invalid header entry
328 cat >tag.sig <<EOF
329 object $head
330 type commit
331 tag mytag
332 tagger T A Gger <tagger@example.com> 1206478233 -0500
333 this line should not be here
337 check_verify_failure 'detect invalid header entry' \
338 '^error: char124: trailing garbage in tag header$'
340 ############################################################
341 # 24. create valid tag
343 cat >tag.sig <<EOF
344 object $head
345 type commit
346 tag mytag
347 tagger T A Gger <tagger@example.com> 1206478233 -0500
351 test_expect_success \
352 'create valid tag' \
353 'git mktag <tag.sig >.git/refs/tags/mytag 2>message'
355 ############################################################
356 # 25. check mytag
358 test_expect_success \
359 'check mytag' \
360 'git tag -l | grep mytag'
363 test_done