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