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