]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3800-mktag.sh
Merge branch 'js/update-index-ignore-removal-for-skip-worktree'
[thirdparty/git.git] / t / t3800-mktag.sh
1 #!/bin/sh
2 #
3 #
4
5 test_description='git mktag: tag object verify test'
6
7 . ./test-lib.sh
8
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.
13
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
19 '
20 }
21
22 ###########################################################
23 # first create a commit, so we have a valid object/type
24 # for the tag.
25 test_expect_success 'setup' '
26 test_oid_init &&
27 echo Hello >A &&
28 git update-index --add A &&
29 git commit -m "Initial commit" &&
30 head=$(git rev-parse --verify HEAD)
31 '
32
33 ############################################################
34 # 1. length check
35
36 cat >tag.sig <<EOF
37 too short for a tag
38 EOF
39
40 check_verify_failure 'Tag object length check' \
41 '^error: .*size wrong.*$'
42
43 ############################################################
44 # 2. object line label check
45
46 cat >tag.sig <<EOF
47 xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895
48 type tag
49 tag mytag
50 tagger . <> 0 +0000
51
52 EOF
53
54 check_verify_failure '"object" line label check' '^error: char0: .*"object "$'
55
56 ############################################################
57 # 3. object line SHA1 check
58
59 cat >tag.sig <<EOF
60 object zz9e9b33986b1c2670fff52c5067603117b3e895
61 type tag
62 tag mytag
63 tagger . <> 0 +0000
64
65 EOF
66
67 check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$'
68
69 ############################################################
70 # 4. type line label check
71
72 cat >tag.sig <<EOF
73 object $head
74 xxxx tag
75 tag mytag
76 tagger . <> 0 +0000
77
78 EOF
79
80 check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$'
81
82 ############################################################
83 # 5. type line eol check
84
85 echo "object $head" >tag.sig
86 printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
87
88 check_verify_failure '"type" line eol check' '^error: char.*: .*"\\n"$'
89
90 ############################################################
91 # 6. tag line label check #1
92
93 cat >tag.sig <<EOF
94 object $head
95 type tag
96 xxx mytag
97 tagger . <> 0 +0000
98
99 EOF
100
101 check_verify_failure '"tag" line label check #1' \
102 '^error: char.*: no "tag " found$'
103
104 ############################################################
105 # 7. tag line label check #2
106
107 cat >tag.sig <<EOF
108 object $head
109 type taggggggggggggggggggggggggggggggg
110 tag
111 EOF
112
113 check_verify_failure '"tag" line label check #2' \
114 '^error: char.*: no "tag " found$'
115
116 ############################################################
117 # 8. type line type-name length check
118
119 cat >tag.sig <<EOF
120 object $head
121 type taggggggggggggggggggggggggggggggg
122 tag mytag
123 EOF
124
125 check_verify_failure '"type" line type-name length check' \
126 '^error: char.*: type too long$'
127
128 ############################################################
129 # 9. verify object (SHA1/type) check
130
131 cat >tag.sig <<EOF
132 object $(test_oid deadbeef)
133 type tagggg
134 tag mytag
135 tagger . <> 0 +0000
136
137 EOF
138
139 check_verify_failure 'verify object (SHA1/type) check' \
140 '^error: char7: could not verify object.*$'
141
142 ############################################################
143 # 10. verify tag-name check
144
145 cat >tag.sig <<EOF
146 object $head
147 type commit
148 tag my tag
149 tagger . <> 0 +0000
150
151 EOF
152
153 check_verify_failure 'verify tag-name check' \
154 '^error: char.*: could not verify tag name$'
155
156 ############################################################
157 # 11. tagger line label check #1
158
159 cat >tag.sig <<EOF
160 object $head
161 type commit
162 tag mytag
163
164 This is filler
165 EOF
166
167 check_verify_failure '"tagger" line label check #1' \
168 '^error: char.*: could not find "tagger "$'
169
170 ############################################################
171 # 12. tagger line label check #2
172
173 cat >tag.sig <<EOF
174 object $head
175 type commit
176 tag mytag
177 tagger
178
179 This is filler
180 EOF
181
182 check_verify_failure '"tagger" line label check #2' \
183 '^error: char.*: could not find "tagger "$'
184
185 ############################################################
186 # 13. disallow missing tag author name
187
188 cat >tag.sig <<EOF
189 object $head
190 type commit
191 tag mytag
192 tagger <> 0 +0000
193
194 This is filler
195 EOF
196
197 check_verify_failure 'disallow missing tag author name' \
198 '^error: char.*: missing tagger name$'
199
200 ############################################################
201 # 14. disallow missing tag author name
202
203 cat >tag.sig <<EOF
204 object $head
205 type commit
206 tag mytag
207 tagger T A Gger <
208 > 0 +0000
209
210 EOF
211
212 check_verify_failure 'disallow malformed tagger' \
213 '^error: char.*: malformed tagger field$'
214
215 ############################################################
216 # 15. allow empty tag email
217
218 cat >tag.sig <<EOF
219 object $head
220 type commit
221 tag mytag
222 tagger T A Gger <> 0 +0000
223
224 EOF
225
226 test_expect_success \
227 'allow empty tag email' \
228 'git mktag <tag.sig >.git/refs/tags/mytag 2>message'
229
230 ############################################################
231 # 16. disallow spaces in tag email
232
233 cat >tag.sig <<EOF
234 object $head
235 type commit
236 tag mytag
237 tagger T A Gger <tag ger@example.com> 0 +0000
238
239 EOF
240
241 check_verify_failure 'disallow spaces in tag email' \
242 '^error: char.*: malformed tagger field$'
243
244 ############################################################
245 # 17. disallow missing tag timestamp
246
247 tr '_' ' ' >tag.sig <<EOF
248 object $head
249 type commit
250 tag mytag
251 tagger T A Gger <tagger@example.com>__
252
253 EOF
254
255 check_verify_failure 'disallow missing tag timestamp' \
256 '^error: char.*: missing tag timestamp$'
257
258 ############################################################
259 # 18. detect invalid tag timestamp1
260
261 cat >tag.sig <<EOF
262 object $head
263 type commit
264 tag mytag
265 tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008
266
267 EOF
268
269 check_verify_failure 'detect invalid tag timestamp1' \
270 '^error: char.*: missing tag timestamp$'
271
272 ############################################################
273 # 19. detect invalid tag timestamp2
274
275 cat >tag.sig <<EOF
276 object $head
277 type commit
278 tag mytag
279 tagger T A Gger <tagger@example.com> 2008-03-31T12:20:15-0500
280
281 EOF
282
283 check_verify_failure 'detect invalid tag timestamp2' \
284 '^error: char.*: malformed tag timestamp$'
285
286 ############################################################
287 # 20. detect invalid tag timezone1
288
289 cat >tag.sig <<EOF
290 object $head
291 type commit
292 tag mytag
293 tagger T A Gger <tagger@example.com> 1206478233 GMT
294
295 EOF
296
297 check_verify_failure 'detect invalid tag timezone1' \
298 '^error: char.*: malformed tag timezone$'
299
300 ############################################################
301 # 21. detect invalid tag timezone2
302
303 cat >tag.sig <<EOF
304 object $head
305 type commit
306 tag mytag
307 tagger T A Gger <tagger@example.com> 1206478233 + 30
308
309 EOF
310
311 check_verify_failure 'detect invalid tag timezone2' \
312 '^error: char.*: malformed tag timezone$'
313
314 ############################################################
315 # 22. detect invalid tag timezone3
316
317 cat >tag.sig <<EOF
318 object $head
319 type commit
320 tag mytag
321 tagger T A Gger <tagger@example.com> 1206478233 -1430
322
323 EOF
324
325 check_verify_failure 'detect invalid tag timezone3' \
326 '^error: char.*: malformed tag timezone$'
327
328 ############################################################
329 # 23. detect invalid header entry
330
331 cat >tag.sig <<EOF
332 object $head
333 type commit
334 tag mytag
335 tagger T A Gger <tagger@example.com> 1206478233 -0500
336 this line should not be here
337
338 EOF
339
340 check_verify_failure 'detect invalid header entry' \
341 '^error: char.*: trailing garbage in tag header$'
342
343 ############################################################
344 # 24. create valid tag
345
346 cat >tag.sig <<EOF
347 object $head
348 type commit
349 tag mytag
350 tagger T A Gger <tagger@example.com> 1206478233 -0500
351
352 EOF
353
354 test_expect_success \
355 'create valid tag' \
356 'git mktag <tag.sig >.git/refs/tags/mytag 2>message'
357
358 ############################################################
359 # 25. check mytag
360
361 test_expect_success \
362 'check mytag' \
363 'git tag -l | grep mytag'
364
365
366 test_done