5 test_description
='git-mktag: tag object verify test'
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
() {
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
26 git update-index
--add A
27 git-commit
-m "Initial commit"
28 head=$
(git rev-parse
--verify HEAD
)
30 ############################################################
37 check_verify_failure
'Tag object length check' \
38 '^error: .*size wrong.*$'
40 ############################################################
41 # 2. object line label check
44 xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895
51 check_verify_failure
'"object" line label check' '^error: char0: .*"object "$'
53 ############################################################
54 # 3. object line SHA1 check
57 object zz9e9b33986b1c2670fff52c5067603117b3e895
64 check_verify_failure
'"object" line SHA1 check' '^error: char7: .*SHA1 hash$'
66 ############################################################
67 # 4. type line label check
70 object 779e9b33986b1c2670fff52c5067603117b3e895
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
91 object 779e9b33986b1c2670fff52c5067603117b3e895
98 check_verify_failure
'"tag" line label check #1' \
99 '^error: char57: no "tag " found$'
101 ############################################################
102 # 7. tag line label check #2
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
117 object 779e9b33986b1c2670fff52c5067603117b3e895
118 type taggggggggggggggggggggggggggggggg
122 check_verify_failure
'"type" line type-name length check' \
123 '^error: char53: type too long$'
125 ############################################################
126 # 9. verify object (SHA1/type) check
129 object 779e9b33986b1c2670fff52c5067603117b3e895
136 check_verify_failure
'verify object (SHA1/type) check' \
137 '^error: char7: could not verify object.*$'
139 ############################################################
140 # 10. verify tag-name check
150 check_verify_failure
'verify tag-name check' \
151 '^error: char67: could not verify tag name$'
153 ############################################################
154 # 11. tagger line label check #1
164 check_verify_failure
'"tagger" line label check #1' \
165 '^error: char70: could not find "tagger "$'
167 ############################################################
168 # 12. tagger line label check #2
179 check_verify_failure
'"tagger" line label check #2' \
180 '^error: char70: could not find "tagger "$'
182 ############################################################
183 # 13. detect missing tag author name
194 check_verify_failure
'detect missing tag author name' \
195 '^error: char77: missing tagger name$'
197 ############################################################
198 # 14. detect missing tag author name
209 check_verify_failure
'detect malformed tagger' \
210 '^error: char77: malformed tagger$'
212 ############################################################
213 # 15. allow empty tag email
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. detect missing tag timestamp
234 tagger T A Gger <tagger@example.com>
238 check_verify_failure
'detect missing tag timestamp' \
239 '^error: char107: malformed tag timestamp$'
241 ############################################################
242 # 17. detect invalid tag timestamp
248 tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008
252 check_verify_failure
'detect invalid tag timestamp' \
253 '^error: char108: malformed tag timestamp$'
255 ############################################################
256 # 18. detect invalid tag timezone
262 tagger T A Gger <tagger@example.com> 1206478233 GMT
266 check_verify_failure
'detect invalid tag timezone' \
267 '^error: char118: malformed tag timezone$'
269 ############################################################
270 # 19. detect invalid header entry
276 tagger T A Gger <tagger@example.com> 1206478233 -0500
277 this line should not be here
281 check_verify_failure
'detect invalid header entry' \
282 '^error: char124: trailing garbage in tag header$'
284 ############################################################
285 # 20. create valid tag
291 tagger T A Gger <tagger@example.com> 1206478233 -0500
295 test_expect_success \
297 'git-mktag <tag.sig >.git/refs/tags/mytag 2>message'
299 ############################################################
302 test_expect_success \
304 'git-tag -l | grep mytag'