]>
Commit | Line | Data |
---|---|---|
ef5a6fb5 CR |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Carlos Rica | |
4 | # | |
5 | ||
d592b315 | 6 | test_description='git tag |
ef5a6fb5 | 7 | |
62e09ce9 | 8 | Tests for operations with tags.' |
ef5a6fb5 CR |
9 | |
10 | . ./test-lib.sh | |
37d3e859 | 11 | . "$TEST_DIRECTORY"/lib-gpg.sh |
11b087ad | 12 | . "$TEST_DIRECTORY"/lib-terminal.sh |
ef5a6fb5 CR |
13 | |
14 | # creating and listing lightweight tags: | |
15 | ||
16 | tag_exists () { | |
17 | git show-ref --quiet --verify refs/tags/"$1" | |
18 | } | |
19 | ||
62e09ce9 CR |
20 | test_expect_success 'listing all tags in an empty tree should succeed' ' |
21 | git tag -l && | |
22 | git tag | |
23 | ' | |
ef5a6fb5 | 24 | |
62e09ce9 | 25 | test_expect_success 'listing all tags in an empty tree should output nothing' ' |
63873a0a EP |
26 | test $(git tag -l | wc -l) -eq 0 && |
27 | test $(git tag | wc -l) -eq 0 | |
62e09ce9 | 28 | ' |
ef5a6fb5 | 29 | |
3bb16a8b NTND |
30 | test_expect_success 'sort tags, ignore case' ' |
31 | ( | |
32 | git init sort && | |
33 | cd sort && | |
34 | test_commit initial && | |
35 | git tag tag-one && | |
36 | git tag TAG-two && | |
37 | git tag -l >actual && | |
38 | cat >expected <<-\EOF && | |
39 | TAG-two | |
40 | initial | |
41 | tag-one | |
42 | EOF | |
43 | test_cmp expected actual && | |
44 | git tag -l -i >actual && | |
45 | cat >expected <<-\EOF && | |
46 | initial | |
47 | tag-one | |
48 | TAG-two | |
49 | EOF | |
50 | test_cmp expected actual | |
51 | ) | |
52 | ' | |
53 | ||
41ac414e JH |
54 | test_expect_success 'looking for a tag in an empty tree should fail' \ |
55 | '! (tag_exists mytag)' | |
ef5a6fb5 CR |
56 | |
57 | test_expect_success 'creating a tag in an empty tree should fail' ' | |
d592b315 | 58 | test_must_fail git tag mynotag && |
ef5a6fb5 CR |
59 | ! tag_exists mynotag |
60 | ' | |
61 | ||
62 | test_expect_success 'creating a tag for HEAD in an empty tree should fail' ' | |
d592b315 | 63 | test_must_fail git tag mytaghead HEAD && |
ef5a6fb5 CR |
64 | ! tag_exists mytaghead |
65 | ' | |
66 | ||
67 | test_expect_success 'creating a tag for an unknown revision should fail' ' | |
d592b315 | 68 | test_must_fail git tag mytagnorev aaaaaaaaaaa && |
ef5a6fb5 CR |
69 | ! tag_exists mytagnorev |
70 | ' | |
71 | ||
72 | # commit used in the tests, test_tick is also called here to freeze the date: | |
73 | test_expect_success 'creating a tag using default HEAD should succeed' ' | |
341fb286 | 74 | test_config core.logAllRefUpdates true && |
ef5a6fb5 CR |
75 | test_tick && |
76 | echo foo >foo && | |
77 | git add foo && | |
78 | git commit -m Foo && | |
144c76fa DT |
79 | git tag mytag && |
80 | test_must_fail git reflog exists refs/tags/mytag | |
81 | ' | |
82 | ||
83 | test_expect_success 'creating a tag with --create-reflog should create reflog' ' | |
df8512ed CW |
84 | git log -1 \ |
85 | --format="format:tag: tagging %h (%s, %cd)%n" \ | |
86 | --date=format:%Y-%m-%d >expected && | |
144c76fa DT |
87 | test_when_finished "git tag -d tag_with_reflog" && |
88 | git tag --create-reflog tag_with_reflog && | |
df8512ed CW |
89 | git reflog exists refs/tags/tag_with_reflog && |
90 | sed -e "s/^.* //" .git/logs/refs/tags/tag_with_reflog >actual && | |
0d75bfe6 | 91 | test_i18ncmp expected actual |
df8512ed CW |
92 | ' |
93 | ||
94 | test_expect_success 'annotated tag with --create-reflog has correct message' ' | |
95 | git log -1 \ | |
96 | --format="format:tag: tagging %h (%s, %cd)%n" \ | |
97 | --date=format:%Y-%m-%d >expected && | |
98 | test_when_finished "git tag -d tag_with_reflog" && | |
99 | git tag -m "annotated tag" --create-reflog tag_with_reflog && | |
100 | git reflog exists refs/tags/tag_with_reflog && | |
101 | sed -e "s/^.* //" .git/logs/refs/tags/tag_with_reflog >actual && | |
0d75bfe6 | 102 | test_i18ncmp expected actual |
144c76fa DT |
103 | ' |
104 | ||
105 | test_expect_success '--create-reflog does not create reflog on failure' ' | |
106 | test_must_fail git tag --create-reflog mytag && | |
107 | test_must_fail git reflog exists refs/tags/mytag | |
ef5a6fb5 CR |
108 | ' |
109 | ||
341fb286 CW |
110 | test_expect_success 'option core.logAllRefUpdates=always creates reflog' ' |
111 | test_when_finished "git tag -d tag_with_reflog" && | |
112 | test_config core.logAllRefUpdates always && | |
113 | git tag tag_with_reflog && | |
114 | git reflog exists refs/tags/tag_with_reflog | |
115 | ' | |
116 | ||
62e09ce9 | 117 | test_expect_success 'listing all tags if one exists should succeed' ' |
d592b315 NS |
118 | git tag -l && |
119 | git tag | |
62e09ce9 | 120 | ' |
ef5a6fb5 | 121 | |
c485b24c ÆAB |
122 | cat >expect <<EOF |
123 | mytag | |
124 | EOF | |
125 | test_expect_success 'Multiple -l or --list options are equivalent to one -l option' ' | |
126 | git tag -l -l >actual && | |
127 | test_cmp expect actual && | |
128 | git tag --list --list >actual && | |
129 | test_cmp expect actual && | |
130 | git tag --list -l --list >actual && | |
131 | test_cmp expect actual | |
132 | ' | |
133 | ||
62e09ce9 | 134 | test_expect_success 'listing all tags if one exists should output that tag' ' |
63873a0a EP |
135 | test $(git tag -l) = mytag && |
136 | test $(git tag) = mytag | |
62e09ce9 | 137 | ' |
ef5a6fb5 CR |
138 | |
139 | # pattern matching: | |
140 | ||
141 | test_expect_success 'listing a tag using a matching pattern should succeed' \ | |
d592b315 | 142 | 'git tag -l mytag' |
ef5a6fb5 | 143 | |
3bb16a8b NTND |
144 | test_expect_success 'listing a tag with --ignore-case' \ |
145 | 'test $(git tag -l --ignore-case MYTAG) = mytag' | |
146 | ||
ef5a6fb5 CR |
147 | test_expect_success \ |
148 | 'listing a tag using a matching pattern should output that tag' \ | |
63873a0a | 149 | 'test $(git tag -l mytag) = mytag' |
ef5a6fb5 | 150 | |
ef5a6fb5 | 151 | test_expect_success \ |
682b29f9 | 152 | 'listing tags using a non-matching pattern should succeed' \ |
d592b315 | 153 | 'git tag -l xxx' |
ef5a6fb5 CR |
154 | |
155 | test_expect_success \ | |
156 | 'listing tags using a non-matching pattern should output nothing' \ | |
63873a0a | 157 | 'test $(git tag -l xxx | wc -l) -eq 0' |
ef5a6fb5 CR |
158 | |
159 | # special cases for creating tags: | |
160 | ||
41ac414e | 161 | test_expect_success \ |
ef5a6fb5 | 162 | 'trying to create a tag with the name of one existing should fail' \ |
d492b31c | 163 | 'test_must_fail git tag mytag' |
ef5a6fb5 CR |
164 | |
165 | test_expect_success \ | |
166 | 'trying to create a tag with a non-valid name should fail' ' | |
63873a0a | 167 | test $(git tag -l | wc -l) -eq 1 && |
d492b31c SB |
168 | test_must_fail git tag "" && |
169 | test_must_fail git tag .othertag && | |
170 | test_must_fail git tag "other tag" && | |
171 | test_must_fail git tag "othertag^" && | |
172 | test_must_fail git tag "other~tag" && | |
63873a0a | 173 | test $(git tag -l | wc -l) -eq 1 |
ef5a6fb5 CR |
174 | ' |
175 | ||
176 | test_expect_success 'creating a tag using HEAD directly should succeed' ' | |
177 | git tag myhead HEAD && | |
178 | tag_exists myhead | |
179 | ' | |
180 | ||
3ae851e6 PH |
181 | test_expect_success '--force can create a tag with the name of one existing' ' |
182 | tag_exists mytag && | |
183 | git tag --force mytag && | |
184 | tag_exists mytag' | |
185 | ||
186 | test_expect_success '--force is moot with a non-existing tag name' ' | |
eba286e3 | 187 | test_when_finished git tag -d newtag forcetag && |
3ae851e6 PH |
188 | git tag newtag >expect && |
189 | git tag --force forcetag >actual && | |
190 | test_cmp expect actual | |
191 | ' | |
3ae851e6 | 192 | |
ef5a6fb5 CR |
193 | # deleting tags: |
194 | ||
195 | test_expect_success 'trying to delete an unknown tag should fail' ' | |
196 | ! tag_exists unknown-tag && | |
d592b315 | 197 | test_must_fail git tag -d unknown-tag |
ef5a6fb5 CR |
198 | ' |
199 | ||
200 | cat >expect <<EOF | |
201 | myhead | |
202 | mytag | |
203 | EOF | |
204 | test_expect_success \ | |
205 | 'trying to delete tags without params should succeed and do nothing' ' | |
3af82863 | 206 | git tag -l > actual && test_cmp expect actual && |
d592b315 | 207 | git tag -d && |
3af82863 | 208 | git tag -l > actual && test_cmp expect actual |
ef5a6fb5 CR |
209 | ' |
210 | ||
211 | test_expect_success \ | |
212 | 'deleting two existing tags in one command should succeed' ' | |
213 | tag_exists mytag && | |
214 | tag_exists myhead && | |
d592b315 | 215 | git tag -d mytag myhead && |
ef5a6fb5 CR |
216 | ! tag_exists mytag && |
217 | ! tag_exists myhead | |
218 | ' | |
219 | ||
220 | test_expect_success \ | |
221 | 'creating a tag with the name of another deleted one should succeed' ' | |
222 | ! tag_exists mytag && | |
d592b315 | 223 | git tag mytag && |
ef5a6fb5 CR |
224 | tag_exists mytag |
225 | ' | |
226 | ||
227 | test_expect_success \ | |
228 | 'trying to delete two tags, existing and not, should fail in the 2nd' ' | |
229 | tag_exists mytag && | |
230 | ! tag_exists myhead && | |
d592b315 | 231 | test_must_fail git tag -d mytag anothertag && |
ef5a6fb5 CR |
232 | ! tag_exists mytag && |
233 | ! tag_exists myhead | |
234 | ' | |
235 | ||
41ac414e | 236 | test_expect_success 'trying to delete an already deleted tag should fail' \ |
d592b315 | 237 | 'test_must_fail git tag -d mytag' |
ef5a6fb5 CR |
238 | |
239 | # listing various tags with pattern matching: | |
240 | ||
241 | cat >expect <<EOF | |
242 | a1 | |
243 | aa1 | |
244 | cba | |
245 | t210 | |
246 | t211 | |
247 | v0.2.1 | |
248 | v1.0 | |
249 | v1.0.1 | |
250 | v1.1.3 | |
251 | EOF | |
252 | test_expect_success 'listing all tags should print them ordered' ' | |
253 | git tag v1.0.1 && | |
254 | git tag t211 && | |
255 | git tag aa1 && | |
256 | git tag v0.2.1 && | |
257 | git tag v1.1.3 && | |
258 | git tag cba && | |
259 | git tag a1 && | |
260 | git tag v1.0 && | |
261 | git tag t210 && | |
5206d130 | 262 | git tag -l > actual && |
3af82863 | 263 | test_cmp expect actual && |
62e09ce9 | 264 | git tag > actual && |
3af82863 | 265 | test_cmp expect actual |
ef5a6fb5 CR |
266 | ' |
267 | ||
268 | cat >expect <<EOF | |
269 | a1 | |
270 | aa1 | |
271 | cba | |
272 | EOF | |
273 | test_expect_success \ | |
274 | 'listing tags with substring as pattern must print those matching' ' | |
0aaaef7b JS |
275 | rm *a* && |
276 | git tag -l "*a*" > current && | |
277 | test_cmp expect current | |
ef5a6fb5 CR |
278 | ' |
279 | ||
280 | cat >expect <<EOF | |
281 | v0.2.1 | |
282 | v1.0.1 | |
ef5a6fb5 CR |
283 | EOF |
284 | test_expect_success \ | |
18e32b5b | 285 | 'listing tags with a suffix as pattern must print those matching' ' |
d592b315 | 286 | git tag -l "*.1" > actual && |
3af82863 | 287 | test_cmp expect actual |
ef5a6fb5 CR |
288 | ' |
289 | ||
290 | cat >expect <<EOF | |
291 | t210 | |
292 | t211 | |
293 | EOF | |
294 | test_expect_success \ | |
18e32b5b | 295 | 'listing tags with a prefix as pattern must print those matching' ' |
d592b315 | 296 | git tag -l "t21*" > actual && |
3af82863 | 297 | test_cmp expect actual |
ef5a6fb5 CR |
298 | ' |
299 | ||
300 | cat >expect <<EOF | |
301 | a1 | |
ef5a6fb5 CR |
302 | EOF |
303 | test_expect_success \ | |
18e32b5b | 304 | 'listing tags using a name as pattern must print that one matching' ' |
d592b315 | 305 | git tag -l a1 > actual && |
3af82863 | 306 | test_cmp expect actual |
ef5a6fb5 CR |
307 | ' |
308 | ||
309 | cat >expect <<EOF | |
310 | v1.0 | |
ef5a6fb5 CR |
311 | EOF |
312 | test_expect_success \ | |
18e32b5b | 313 | 'listing tags using a name as pattern must print that one matching' ' |
d592b315 | 314 | git tag -l v1.0 > actual && |
3af82863 | 315 | test_cmp expect actual |
ef5a6fb5 CR |
316 | ' |
317 | ||
318 | cat >expect <<EOF | |
18e32b5b | 319 | v1.0.1 |
ef5a6fb5 CR |
320 | v1.1.3 |
321 | EOF | |
322 | test_expect_success \ | |
323 | 'listing tags with ? in the pattern should print those matching' ' | |
d592b315 | 324 | git tag -l "v1.?.?" > actual && |
3af82863 | 325 | test_cmp expect actual |
ef5a6fb5 CR |
326 | ' |
327 | ||
328 | >expect | |
329 | test_expect_success \ | |
330 | 'listing tags using v.* should print nothing because none have v.' ' | |
d592b315 | 331 | git tag -l "v.*" > actual && |
3af82863 | 332 | test_cmp expect actual |
ef5a6fb5 CR |
333 | ' |
334 | ||
335 | cat >expect <<EOF | |
336 | v0.2.1 | |
337 | v1.0 | |
338 | v1.0.1 | |
339 | v1.1.3 | |
340 | EOF | |
341 | test_expect_success \ | |
342 | 'listing tags using v* should print only those having v' ' | |
d592b315 | 343 | git tag -l "v*" > actual && |
3af82863 | 344 | test_cmp expect actual |
ef5a6fb5 CR |
345 | ' |
346 | ||
588d0e83 JK |
347 | test_expect_success 'tag -l can accept multiple patterns' ' |
348 | git tag -l "v1*" "v0*" >actual && | |
349 | test_cmp expect actual | |
350 | ' | |
351 | ||
c485b24c ÆAB |
352 | # Between v1.7.7 & v2.13.0 a fair reading of the git-tag documentation |
353 | # could leave you with the impression that "-l <pattern> -l <pattern>" | |
354 | # was how we wanted to accept multiple patterns. | |
355 | # | |
356 | # This test should not imply that this is a sane thing to support. but | |
357 | # since the documentation was worded like it was let's at least find | |
358 | # out if we're going to break this long-documented form of taking | |
359 | # multiple patterns. | |
360 | test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documentation previously suggested' ' | |
361 | git tag -l "v1*" -l "v0*" >actual && | |
362 | test_cmp expect actual | |
363 | ' | |
364 | ||
d96e3c15 NTND |
365 | test_expect_success 'listing tags in column' ' |
366 | COLUMNS=40 git tag -l --column=row >actual && | |
367 | cat >expected <<\EOF && | |
368 | a1 aa1 cba t210 t211 | |
369 | v0.2.1 v1.0 v1.0.1 v1.1.3 | |
370 | EOF | |
371 | test_cmp expected actual | |
372 | ' | |
373 | ||
374 | test_expect_success 'listing tags in column with column.*' ' | |
9ffda48f SG |
375 | test_config column.tag row && |
376 | test_config column.ui dense && | |
d96e3c15 | 377 | COLUMNS=40 git tag -l >actual && |
d96e3c15 NTND |
378 | cat >expected <<\EOF && |
379 | a1 aa1 cba t210 t211 | |
380 | v0.2.1 v1.0 v1.0.1 v1.1.3 | |
381 | EOF | |
382 | test_cmp expected actual | |
383 | ' | |
384 | ||
385 | test_expect_success 'listing tag with -n --column should fail' ' | |
386 | test_must_fail git tag --column -n | |
387 | ' | |
388 | ||
389 | test_expect_success 'listing tags -n in column with column.ui ignored' ' | |
9ffda48f | 390 | test_config column.ui "row dense" && |
d96e3c15 | 391 | COLUMNS=40 git tag -l -n >actual && |
d96e3c15 NTND |
392 | cat >expected <<\EOF && |
393 | a1 Foo | |
394 | aa1 Foo | |
395 | cba Foo | |
396 | t210 Foo | |
397 | t211 Foo | |
398 | v0.2.1 Foo | |
399 | v1.0 Foo | |
400 | v1.0.1 Foo | |
401 | v1.1.3 Foo | |
402 | EOF | |
403 | test_cmp expected actual | |
404 | ' | |
405 | ||
ef5a6fb5 CR |
406 | # creating and verifying lightweight tags: |
407 | ||
408 | test_expect_success \ | |
409 | 'a non-annotated tag created without parameters should point to HEAD' ' | |
d592b315 | 410 | git tag non-annotated-tag && |
5be60078 JH |
411 | test $(git cat-file -t non-annotated-tag) = commit && |
412 | test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD) | |
ef5a6fb5 CR |
413 | ' |
414 | ||
41ac414e | 415 | test_expect_success 'trying to verify an unknown tag should fail' \ |
d592b315 | 416 | 'test_must_fail git tag -v unknown-tag' |
ef5a6fb5 | 417 | |
41ac414e | 418 | test_expect_success \ |
ef5a6fb5 | 419 | 'trying to verify a non-annotated and non-signed tag should fail' \ |
d592b315 | 420 | 'test_must_fail git tag -v non-annotated-tag' |
ef5a6fb5 | 421 | |
41ac414e | 422 | test_expect_success \ |
62e09ce9 | 423 | 'trying to verify many non-annotated or unknown tags, should fail' \ |
d592b315 | 424 | 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2' |
62e09ce9 | 425 | |
ef5a6fb5 CR |
426 | # creating annotated tags: |
427 | ||
428 | get_tag_msg () { | |
429 | git cat-file tag "$1" | sed -e "/BEGIN PGP/q" | |
430 | } | |
431 | ||
432 | # run test_tick before committing always gives the time in that timezone | |
433 | get_tag_header () { | |
434 | cat <<EOF | |
435 | object $2 | |
436 | type $3 | |
437 | tag $1 | |
438 | tagger C O Mitter <committer@example.com> $4 -0700 | |
439 | ||
440 | EOF | |
441 | } | |
442 | ||
443 | commit=$(git rev-parse HEAD) | |
444 | time=$test_tick | |
445 | ||
446 | get_tag_header annotated-tag $commit commit $time >expect | |
447 | echo "A message" >>expect | |
448 | test_expect_success \ | |
449 | 'creating an annotated tag with -m message should succeed' ' | |
d592b315 | 450 | git tag -m "A message" annotated-tag && |
ef5a6fb5 | 451 | get_tag_msg annotated-tag >actual && |
3af82863 | 452 | test_cmp expect actual |
ef5a6fb5 CR |
453 | ' |
454 | ||
455 | cat >msgfile <<EOF | |
456 | Another message | |
457 | in a file. | |
458 | EOF | |
459 | get_tag_header file-annotated-tag $commit commit $time >expect | |
460 | cat msgfile >>expect | |
461 | test_expect_success \ | |
462 | 'creating an annotated tag with -F messagefile should succeed' ' | |
d592b315 | 463 | git tag -F msgfile file-annotated-tag && |
ef5a6fb5 | 464 | get_tag_msg file-annotated-tag >actual && |
3af82863 | 465 | test_cmp expect actual |
ef5a6fb5 CR |
466 | ' |
467 | ||
62e09ce9 CR |
468 | cat >inputmsg <<EOF |
469 | A message from the | |
470 | standard input | |
471 | EOF | |
472 | get_tag_header stdin-annotated-tag $commit commit $time >expect | |
473 | cat inputmsg >>expect | |
474 | test_expect_success 'creating an annotated tag with -F - should succeed' ' | |
d592b315 | 475 | git tag -F - stdin-annotated-tag <inputmsg && |
62e09ce9 | 476 | get_tag_msg stdin-annotated-tag >actual && |
3af82863 | 477 | test_cmp expect actual |
62e09ce9 CR |
478 | ' |
479 | ||
e317cfaf CR |
480 | test_expect_success \ |
481 | 'trying to create a tag with a non-existing -F file should fail' ' | |
482 | ! test -f nonexistingfile && | |
483 | ! tag_exists notag && | |
d592b315 | 484 | test_must_fail git tag -F nonexistingfile notag && |
e317cfaf CR |
485 | ! tag_exists notag |
486 | ' | |
487 | ||
488 | test_expect_success \ | |
39686585 | 489 | 'trying to create tags giving both -m or -F options should fail' ' |
e317cfaf CR |
490 | echo "message file 1" >msgfile1 && |
491 | echo "message file 2" >msgfile2 && | |
492 | ! tag_exists msgtag && | |
d592b315 | 493 | test_must_fail git tag -m "message 1" -F msgfile1 msgtag && |
e317cfaf | 494 | ! tag_exists msgtag && |
d592b315 | 495 | test_must_fail git tag -F msgfile1 -m "message 1" msgtag && |
e317cfaf | 496 | ! tag_exists msgtag && |
d592b315 | 497 | test_must_fail git tag -m "message 1" -F msgfile1 \ |
d492b31c | 498 | -m "message 2" msgtag && |
e317cfaf CR |
499 | ! tag_exists msgtag |
500 | ' | |
501 | ||
ef5a6fb5 CR |
502 | # blank and empty messages: |
503 | ||
504 | get_tag_header empty-annotated-tag $commit commit $time >expect | |
505 | test_expect_success \ | |
506 | 'creating a tag with an empty -m message should succeed' ' | |
d592b315 | 507 | git tag -m "" empty-annotated-tag && |
ef5a6fb5 | 508 | get_tag_msg empty-annotated-tag >actual && |
3af82863 | 509 | test_cmp expect actual |
ef5a6fb5 CR |
510 | ' |
511 | ||
512 | >emptyfile | |
513 | get_tag_header emptyfile-annotated-tag $commit commit $time >expect | |
514 | test_expect_success \ | |
515 | 'creating a tag with an empty -F messagefile should succeed' ' | |
d592b315 | 516 | git tag -F emptyfile emptyfile-annotated-tag && |
ef5a6fb5 | 517 | get_tag_msg emptyfile-annotated-tag >actual && |
3af82863 | 518 | test_cmp expect actual |
ef5a6fb5 CR |
519 | ' |
520 | ||
521 | printf '\n\n \n\t\nLeading blank lines\n' >blanksfile | |
522 | printf '\n\t \t \nRepeated blank lines\n' >>blanksfile | |
523 | printf '\n\n\nTrailing spaces \t \n' >>blanksfile | |
524 | printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile | |
525 | get_tag_header blanks-annotated-tag $commit commit $time >expect | |
526 | cat >>expect <<EOF | |
527 | Leading blank lines | |
528 | ||
529 | Repeated blank lines | |
530 | ||
531 | Trailing spaces | |
532 | ||
533 | Trailing blank lines | |
534 | EOF | |
535 | test_expect_success \ | |
536 | 'extra blanks in the message for an annotated tag should be removed' ' | |
d592b315 | 537 | git tag -F blanksfile blanks-annotated-tag && |
ef5a6fb5 | 538 | get_tag_msg blanks-annotated-tag >actual && |
3af82863 | 539 | test_cmp expect actual |
ef5a6fb5 CR |
540 | ' |
541 | ||
542 | get_tag_header blank-annotated-tag $commit commit $time >expect | |
543 | test_expect_success \ | |
544 | 'creating a tag with blank -m message with spaces should succeed' ' | |
d592b315 | 545 | git tag -m " " blank-annotated-tag && |
ef5a6fb5 | 546 | get_tag_msg blank-annotated-tag >actual && |
3af82863 | 547 | test_cmp expect actual |
ef5a6fb5 CR |
548 | ' |
549 | ||
550 | echo ' ' >blankfile | |
551 | echo '' >>blankfile | |
552 | echo ' ' >>blankfile | |
553 | get_tag_header blankfile-annotated-tag $commit commit $time >expect | |
554 | test_expect_success \ | |
555 | 'creating a tag with blank -F messagefile with spaces should succeed' ' | |
d592b315 | 556 | git tag -F blankfile blankfile-annotated-tag && |
ef5a6fb5 | 557 | get_tag_msg blankfile-annotated-tag >actual && |
3af82863 | 558 | test_cmp expect actual |
ef5a6fb5 CR |
559 | ' |
560 | ||
561 | printf ' ' >blanknonlfile | |
562 | get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect | |
563 | test_expect_success \ | |
564 | 'creating a tag with -F file of spaces and no newline should succeed' ' | |
d592b315 | 565 | git tag -F blanknonlfile blanknonlfile-annotated-tag && |
ef5a6fb5 | 566 | get_tag_msg blanknonlfile-annotated-tag >actual && |
3af82863 | 567 | test_cmp expect actual |
ef5a6fb5 CR |
568 | ' |
569 | ||
570 | # messages with commented lines: | |
571 | ||
572 | cat >commentsfile <<EOF | |
573 | # A comment | |
574 | ||
575 | ############ | |
576 | The message. | |
577 | ############ | |
578 | One line. | |
579 | ||
580 | ||
581 | # commented lines | |
582 | # commented lines | |
583 | ||
584 | Another line. | |
585 | # comments | |
586 | ||
587 | Last line. | |
588 | EOF | |
589 | get_tag_header comments-annotated-tag $commit commit $time >expect | |
590 | cat >>expect <<EOF | |
591 | The message. | |
592 | One line. | |
593 | ||
594 | Another line. | |
595 | ||
596 | Last line. | |
597 | EOF | |
598 | test_expect_success \ | |
599 | 'creating a tag using a -F messagefile with #comments should succeed' ' | |
d592b315 | 600 | git tag -F commentsfile comments-annotated-tag && |
ef5a6fb5 | 601 | get_tag_msg comments-annotated-tag >actual && |
3af82863 | 602 | test_cmp expect actual |
ef5a6fb5 CR |
603 | ' |
604 | ||
605 | get_tag_header comment-annotated-tag $commit commit $time >expect | |
606 | test_expect_success \ | |
607 | 'creating a tag with a #comment in the -m message should succeed' ' | |
d592b315 | 608 | git tag -m "#comment" comment-annotated-tag && |
ef5a6fb5 | 609 | get_tag_msg comment-annotated-tag >actual && |
3af82863 | 610 | test_cmp expect actual |
ef5a6fb5 CR |
611 | ' |
612 | ||
613 | echo '#comment' >commentfile | |
614 | echo '' >>commentfile | |
615 | echo '####' >>commentfile | |
616 | get_tag_header commentfile-annotated-tag $commit commit $time >expect | |
617 | test_expect_success \ | |
618 | 'creating a tag with #comments in the -F messagefile should succeed' ' | |
d592b315 | 619 | git tag -F commentfile commentfile-annotated-tag && |
ef5a6fb5 | 620 | get_tag_msg commentfile-annotated-tag >actual && |
3af82863 | 621 | test_cmp expect actual |
ef5a6fb5 CR |
622 | ' |
623 | ||
624 | printf '#comment' >commentnonlfile | |
625 | get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect | |
626 | test_expect_success \ | |
627 | 'creating a tag with a file of #comment and no newline should succeed' ' | |
d592b315 | 628 | git tag -F commentnonlfile commentnonlfile-annotated-tag && |
ef5a6fb5 | 629 | get_tag_msg commentnonlfile-annotated-tag >actual && |
3af82863 | 630 | test_cmp expect actual |
ef5a6fb5 CR |
631 | ' |
632 | ||
5206d130 CR |
633 | # listing messages for annotated non-signed tags: |
634 | ||
635 | test_expect_success \ | |
636 | 'listing the one-line message of a non-signed tag should succeed' ' | |
d592b315 | 637 | git tag -m "A msg" tag-one-line && |
5206d130 CR |
638 | |
639 | echo "tag-one-line" >expect && | |
d592b315 | 640 | git tag -l | grep "^tag-one-line" >actual && |
3af82863 | 641 | test_cmp expect actual && |
d592b315 | 642 | git tag -n0 -l | grep "^tag-one-line" >actual && |
3af82863 | 643 | test_cmp expect actual && |
d592b315 | 644 | git tag -n0 -l tag-one-line >actual && |
3af82863 | 645 | test_cmp expect actual && |
5206d130 | 646 | |
6a338149 ÆAB |
647 | git tag -n0 | grep "^tag-one-line" >actual && |
648 | test_cmp expect actual && | |
649 | git tag -n0 tag-one-line >actual && | |
650 | test_cmp expect actual && | |
651 | ||
5206d130 | 652 | echo "tag-one-line A msg" >expect && |
d592b315 | 653 | git tag -n1 -l | grep "^tag-one-line" >actual && |
3af82863 | 654 | test_cmp expect actual && |
d592b315 | 655 | git tag -n -l | grep "^tag-one-line" >actual && |
3af82863 | 656 | test_cmp expect actual && |
d592b315 | 657 | git tag -n1 -l tag-one-line >actual && |
3af82863 | 658 | test_cmp expect actual && |
d592b315 | 659 | git tag -n2 -l tag-one-line >actual && |
3af82863 | 660 | test_cmp expect actual && |
d592b315 | 661 | git tag -n999 -l tag-one-line >actual && |
3af82863 | 662 | test_cmp expect actual |
5206d130 CR |
663 | ' |
664 | ||
6a338149 ÆAB |
665 | test_expect_success 'The -n 100 invocation means -n --list 100, not -n100' ' |
666 | >expect && | |
667 | git tag -n 100 >actual && | |
668 | test_cmp expect actual && | |
669 | ||
670 | git tag -m "A msg" 100 && | |
671 | echo "100 A msg" >expect && | |
672 | git tag -n 100 >actual && | |
673 | test_cmp expect actual | |
674 | ' | |
675 | ||
5206d130 CR |
676 | test_expect_success \ |
677 | 'listing the zero-lines message of a non-signed tag should succeed' ' | |
d592b315 | 678 | git tag -m "" tag-zero-lines && |
5206d130 CR |
679 | |
680 | echo "tag-zero-lines" >expect && | |
d592b315 | 681 | git tag -l | grep "^tag-zero-lines" >actual && |
3af82863 | 682 | test_cmp expect actual && |
d592b315 | 683 | git tag -n0 -l | grep "^tag-zero-lines" >actual && |
3af82863 | 684 | test_cmp expect actual && |
d592b315 | 685 | git tag -n0 -l tag-zero-lines >actual && |
3af82863 | 686 | test_cmp expect actual && |
5206d130 CR |
687 | |
688 | echo "tag-zero-lines " >expect && | |
d592b315 | 689 | git tag -n1 -l | grep "^tag-zero-lines" >actual && |
3af82863 | 690 | test_cmp expect actual && |
d592b315 | 691 | git tag -n -l | grep "^tag-zero-lines" >actual && |
3af82863 | 692 | test_cmp expect actual && |
d592b315 | 693 | git tag -n1 -l tag-zero-lines >actual && |
3af82863 | 694 | test_cmp expect actual && |
d592b315 | 695 | git tag -n2 -l tag-zero-lines >actual && |
3af82863 | 696 | test_cmp expect actual && |
d592b315 | 697 | git tag -n999 -l tag-zero-lines >actual && |
3af82863 | 698 | test_cmp expect actual |
5206d130 CR |
699 | ' |
700 | ||
701 | echo 'tag line one' >annotagmsg | |
702 | echo 'tag line two' >>annotagmsg | |
703 | echo 'tag line three' >>annotagmsg | |
704 | test_expect_success \ | |
705 | 'listing many message lines of a non-signed tag should succeed' ' | |
d592b315 | 706 | git tag -F annotagmsg tag-lines && |
5206d130 CR |
707 | |
708 | echo "tag-lines" >expect && | |
d592b315 | 709 | git tag -l | grep "^tag-lines" >actual && |
3af82863 | 710 | test_cmp expect actual && |
d592b315 | 711 | git tag -n0 -l | grep "^tag-lines" >actual && |
3af82863 | 712 | test_cmp expect actual && |
d592b315 | 713 | git tag -n0 -l tag-lines >actual && |
3af82863 | 714 | test_cmp expect actual && |
5206d130 CR |
715 | |
716 | echo "tag-lines tag line one" >expect && | |
d592b315 | 717 | git tag -n1 -l | grep "^tag-lines" >actual && |
3af82863 | 718 | test_cmp expect actual && |
d592b315 | 719 | git tag -n -l | grep "^tag-lines" >actual && |
3af82863 | 720 | test_cmp expect actual && |
d592b315 | 721 | git tag -n1 -l tag-lines >actual && |
3af82863 | 722 | test_cmp expect actual && |
5206d130 CR |
723 | |
724 | echo " tag line two" >>expect && | |
d592b315 | 725 | git tag -n2 -l | grep "^ *tag.line" >actual && |
3af82863 | 726 | test_cmp expect actual && |
d592b315 | 727 | git tag -n2 -l tag-lines >actual && |
3af82863 | 728 | test_cmp expect actual && |
5206d130 CR |
729 | |
730 | echo " tag line three" >>expect && | |
d592b315 | 731 | git tag -n3 -l | grep "^ *tag.line" >actual && |
3af82863 | 732 | test_cmp expect actual && |
d592b315 | 733 | git tag -n3 -l tag-lines >actual && |
3af82863 | 734 | test_cmp expect actual && |
d592b315 | 735 | git tag -n4 -l | grep "^ *tag.line" >actual && |
3af82863 | 736 | test_cmp expect actual && |
d592b315 | 737 | git tag -n4 -l tag-lines >actual && |
3af82863 | 738 | test_cmp expect actual && |
d592b315 | 739 | git tag -n99 -l | grep "^ *tag.line" >actual && |
3af82863 | 740 | test_cmp expect actual && |
d592b315 | 741 | git tag -n99 -l tag-lines >actual && |
3af82863 | 742 | test_cmp expect actual |
5206d130 CR |
743 | ' |
744 | ||
31fd8d72 JH |
745 | test_expect_success 'annotations for blobs are empty' ' |
746 | blob=$(git hash-object -w --stdin <<-\EOF | |
747 | Blob paragraph 1. | |
748 | ||
749 | Blob paragraph 2. | |
750 | EOF | |
751 | ) && | |
752 | git tag tag-blob $blob && | |
753 | echo "tag-blob " >expect && | |
754 | git tag -n1 -l tag-blob >actual && | |
755 | test_cmp expect actual | |
756 | ' | |
757 | ||
ef5a6fb5 CR |
758 | # trying to verify annotated non-signed tags: |
759 | ||
a4df22ce | 760 | test_expect_success GPG \ |
ef5a6fb5 CR |
761 | 'trying to verify an annotated non-signed tag should fail' ' |
762 | tag_exists annotated-tag && | |
d592b315 | 763 | test_must_fail git tag -v annotated-tag |
ef5a6fb5 CR |
764 | ' |
765 | ||
a4df22ce | 766 | test_expect_success GPG \ |
ef5a6fb5 CR |
767 | 'trying to verify a file-annotated non-signed tag should fail' ' |
768 | tag_exists file-annotated-tag && | |
d592b315 | 769 | test_must_fail git tag -v file-annotated-tag |
ef5a6fb5 CR |
770 | ' |
771 | ||
a4df22ce | 772 | test_expect_success GPG \ |
62e09ce9 CR |
773 | 'trying to verify two annotated non-signed tags should fail' ' |
774 | tag_exists annotated-tag file-annotated-tag && | |
d592b315 | 775 | test_must_fail git tag -v annotated-tag file-annotated-tag |
62e09ce9 CR |
776 | ' |
777 | ||
ef5a6fb5 CR |
778 | # creating and verifying signed tags: |
779 | ||
ef5a6fb5 CR |
780 | get_tag_header signed-tag $commit commit $time >expect |
781 | echo 'A signed tag message' >>expect | |
782 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 783 | test_expect_success GPG 'creating a signed tag with -m message should succeed' ' |
d592b315 | 784 | git tag -s -m "A signed tag message" signed-tag && |
ef5a6fb5 | 785 | get_tag_msg signed-tag >actual && |
3af82863 | 786 | test_cmp expect actual |
ef5a6fb5 CR |
787 | ' |
788 | ||
be15f505 LT |
789 | get_tag_header u-signed-tag $commit commit $time >expect |
790 | echo 'Another message' >>expect | |
791 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 792 | test_expect_success GPG 'sign with a given key id' ' |
be15f505 LT |
793 | |
794 | git tag -u committer@example.com -m "Another message" u-signed-tag && | |
795 | get_tag_msg u-signed-tag >actual && | |
3af82863 | 796 | test_cmp expect actual |
be15f505 LT |
797 | |
798 | ' | |
799 | ||
a4df22ce | 800 | test_expect_success GPG 'sign with an unknown id (1)' ' |
be15f505 | 801 | |
d492b31c SB |
802 | test_must_fail git tag -u author@example.com \ |
803 | -m "Another message" o-signed-tag | |
be15f505 LT |
804 | |
805 | ' | |
806 | ||
a4df22ce | 807 | test_expect_success GPG 'sign with an unknown id (2)' ' |
be15f505 | 808 | |
d492b31c | 809 | test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag |
be15f505 LT |
810 | |
811 | ' | |
812 | ||
813 | cat >fakeeditor <<'EOF' | |
814 | #!/bin/sh | |
815 | test -n "$1" && exec >"$1" | |
816 | echo A signed tag message | |
817 | echo from a fake editor. | |
818 | EOF | |
819 | chmod +x fakeeditor | |
820 | ||
821 | get_tag_header implied-sign $commit commit $time >expect | |
822 | ./fakeeditor >>expect | |
823 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 824 | test_expect_success GPG '-u implies signed tag' ' |
d592b315 | 825 | GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign && |
be15f505 | 826 | get_tag_msg implied-sign >actual && |
3af82863 | 827 | test_cmp expect actual |
be15f505 LT |
828 | ' |
829 | ||
62e09ce9 CR |
830 | cat >sigmsgfile <<EOF |
831 | Another signed tag | |
832 | message in a file. | |
833 | EOF | |
834 | get_tag_header file-signed-tag $commit commit $time >expect | |
835 | cat sigmsgfile >>expect | |
836 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 837 | test_expect_success GPG \ |
62e09ce9 | 838 | 'creating a signed tag with -F messagefile should succeed' ' |
d592b315 | 839 | git tag -s -F sigmsgfile file-signed-tag && |
62e09ce9 | 840 | get_tag_msg file-signed-tag >actual && |
3af82863 | 841 | test_cmp expect actual |
62e09ce9 CR |
842 | ' |
843 | ||
844 | cat >siginputmsg <<EOF | |
845 | A signed tag message from | |
846 | the standard input | |
847 | EOF | |
848 | get_tag_header stdin-signed-tag $commit commit $time >expect | |
849 | cat siginputmsg >>expect | |
850 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 851 | test_expect_success GPG 'creating a signed tag with -F - should succeed' ' |
d592b315 | 852 | git tag -s -F - stdin-signed-tag <siginputmsg && |
62e09ce9 | 853 | get_tag_msg stdin-signed-tag >actual && |
3af82863 | 854 | test_cmp expect actual |
62e09ce9 CR |
855 | ' |
856 | ||
10507857 JK |
857 | get_tag_header implied-annotate $commit commit $time >expect |
858 | ./fakeeditor >>expect | |
859 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 860 | test_expect_success GPG '-s implies annotated tag' ' |
d592b315 | 861 | GIT_EDITOR=./fakeeditor git tag -s implied-annotate && |
10507857 | 862 | get_tag_msg implied-annotate >actual && |
3af82863 | 863 | test_cmp expect actual |
10507857 JK |
864 | ' |
865 | ||
61c2fe0c LA |
866 | get_tag_header forcesignannotated-implied-sign $commit commit $time >expect |
867 | echo "A message" >>expect | |
868 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
869 | test_expect_success GPG \ | |
870 | 'git tag -s implied if configured with tag.forcesignannotated' \ | |
871 | 'test_config tag.forcesignannotated true && | |
872 | git tag -m "A message" forcesignannotated-implied-sign && | |
873 | get_tag_msg forcesignannotated-implied-sign >actual && | |
874 | test_cmp expect actual | |
875 | ' | |
876 | ||
877 | test_expect_success GPG \ | |
878 | 'lightweight with no message when configured with tag.forcesignannotated' \ | |
879 | 'test_config tag.forcesignannotated true && | |
880 | git tag forcesignannotated-lightweight && | |
881 | tag_exists forcesignannotated-lightweight && | |
882 | test_must_fail git tag -v forcesignannotated-no-message | |
883 | ' | |
884 | ||
885 | get_tag_header forcesignannotated-annotate $commit commit $time >expect | |
886 | echo "A message" >>expect | |
887 | test_expect_success GPG \ | |
888 | 'git tag -a disable configured tag.forcesignannotated' \ | |
889 | 'test_config tag.forcesignannotated true && | |
890 | git tag -a -m "A message" forcesignannotated-annotate && | |
891 | get_tag_msg forcesignannotated-annotate >actual && | |
892 | test_cmp expect actual && | |
893 | test_must_fail git tag -v forcesignannotated-annotate | |
894 | ' | |
895 | ||
896 | get_tag_header forcesignannotated-disabled $commit commit $time >expect | |
897 | echo "A message" >>expect | |
898 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
899 | test_expect_success GPG \ | |
900 | 'git tag --sign enable GPG sign' \ | |
901 | 'test_config tag.forcesignannotated false && | |
902 | git tag --sign -m "A message" forcesignannotated-disabled && | |
903 | get_tag_msg forcesignannotated-disabled >actual && | |
904 | test_cmp expect actual | |
905 | ' | |
906 | ||
a4df22ce | 907 | test_expect_success GPG \ |
e317cfaf CR |
908 | 'trying to create a signed tag with non-existing -F file should fail' ' |
909 | ! test -f nonexistingfile && | |
910 | ! tag_exists nosigtag && | |
d592b315 | 911 | test_must_fail git tag -s -F nonexistingfile nosigtag && |
e317cfaf CR |
912 | ! tag_exists nosigtag |
913 | ' | |
914 | ||
a4df22ce | 915 | test_expect_success GPG 'verifying a signed tag should succeed' \ |
d592b315 | 916 | 'git tag -v signed-tag' |
ef5a6fb5 | 917 | |
a4df22ce | 918 | test_expect_success GPG 'verifying two signed tags in one command should succeed' \ |
d592b315 | 919 | 'git tag -v signed-tag file-signed-tag' |
62e09ce9 | 920 | |
a4df22ce | 921 | test_expect_success GPG \ |
62e09ce9 | 922 | 'verifying many signed and non-signed tags should fail' ' |
d592b315 NS |
923 | test_must_fail git tag -v signed-tag annotated-tag && |
924 | test_must_fail git tag -v file-annotated-tag file-signed-tag && | |
925 | test_must_fail git tag -v annotated-tag \ | |
d492b31c | 926 | file-signed-tag file-annotated-tag && |
d592b315 | 927 | test_must_fail git tag -v signed-tag annotated-tag file-signed-tag |
62e09ce9 CR |
928 | ' |
929 | ||
a4df22ce | 930 | test_expect_success GPG 'verifying a forged tag should fail' ' |
ef5a6fb5 CR |
931 | forged=$(git cat-file tag signed-tag | |
932 | sed -e "s/signed-tag/forged-tag/" | | |
933 | git mktag) && | |
934 | git tag forged-tag $forged && | |
d592b315 | 935 | test_must_fail git tag -v forged-tag |
ef5a6fb5 CR |
936 | ' |
937 | ||
b42ca35e ST |
938 | test_expect_success GPG 'verifying a proper tag with --format pass and format accordingly' ' |
939 | cat >expect <<-\EOF && | |
4fea72f4 | 940 | tagname : signed-tag |
b42ca35e | 941 | EOF |
4fea72f4 ST |
942 | git tag -v --format="tagname : %(tag)" "signed-tag" >actual && |
943 | test_cmp expect actual | |
944 | ' | |
945 | ||
b42ca35e ST |
946 | test_expect_success GPG 'verifying a forged tag with --format should fail silently' ' |
947 | >expect && | |
4fea72f4 ST |
948 | test_must_fail git tag -v --format="tagname : %(tag)" "forged-tag" >actual && |
949 | test_cmp expect actual | |
950 | ' | |
951 | ||
ef5a6fb5 CR |
952 | # blank and empty messages for signed tags: |
953 | ||
954 | get_tag_header empty-signed-tag $commit commit $time >expect | |
955 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 956 | test_expect_success GPG \ |
ef5a6fb5 | 957 | 'creating a signed tag with an empty -m message should succeed' ' |
d592b315 | 958 | git tag -s -m "" empty-signed-tag && |
ef5a6fb5 | 959 | get_tag_msg empty-signed-tag >actual && |
3af82863 | 960 | test_cmp expect actual && |
d592b315 | 961 | git tag -v empty-signed-tag |
ef5a6fb5 CR |
962 | ' |
963 | ||
964 | >sigemptyfile | |
965 | get_tag_header emptyfile-signed-tag $commit commit $time >expect | |
966 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 967 | test_expect_success GPG \ |
ef5a6fb5 | 968 | 'creating a signed tag with an empty -F messagefile should succeed' ' |
d592b315 | 969 | git tag -s -F sigemptyfile emptyfile-signed-tag && |
ef5a6fb5 | 970 | get_tag_msg emptyfile-signed-tag >actual && |
3af82863 | 971 | test_cmp expect actual && |
d592b315 | 972 | git tag -v emptyfile-signed-tag |
ef5a6fb5 CR |
973 | ' |
974 | ||
975 | printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile | |
976 | printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile | |
977 | printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile | |
978 | printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile | |
979 | get_tag_header blanks-signed-tag $commit commit $time >expect | |
980 | cat >>expect <<EOF | |
981 | Leading blank lines | |
982 | ||
983 | Repeated blank lines | |
984 | ||
985 | Trailing spaces | |
986 | ||
987 | Trailing blank lines | |
988 | EOF | |
989 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 990 | test_expect_success GPG \ |
ef5a6fb5 | 991 | 'extra blanks in the message for a signed tag should be removed' ' |
d592b315 | 992 | git tag -s -F sigblanksfile blanks-signed-tag && |
ef5a6fb5 | 993 | get_tag_msg blanks-signed-tag >actual && |
3af82863 | 994 | test_cmp expect actual && |
d592b315 | 995 | git tag -v blanks-signed-tag |
ef5a6fb5 CR |
996 | ' |
997 | ||
998 | get_tag_header blank-signed-tag $commit commit $time >expect | |
999 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1000 | test_expect_success GPG \ |
ef5a6fb5 | 1001 | 'creating a signed tag with a blank -m message should succeed' ' |
d592b315 | 1002 | git tag -s -m " " blank-signed-tag && |
ef5a6fb5 | 1003 | get_tag_msg blank-signed-tag >actual && |
3af82863 | 1004 | test_cmp expect actual && |
d592b315 | 1005 | git tag -v blank-signed-tag |
ef5a6fb5 CR |
1006 | ' |
1007 | ||
1008 | echo ' ' >sigblankfile | |
1009 | echo '' >>sigblankfile | |
1010 | echo ' ' >>sigblankfile | |
1011 | get_tag_header blankfile-signed-tag $commit commit $time >expect | |
1012 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1013 | test_expect_success GPG \ |
ef5a6fb5 | 1014 | 'creating a signed tag with blank -F file with spaces should succeed' ' |
d592b315 | 1015 | git tag -s -F sigblankfile blankfile-signed-tag && |
ef5a6fb5 | 1016 | get_tag_msg blankfile-signed-tag >actual && |
3af82863 | 1017 | test_cmp expect actual && |
d592b315 | 1018 | git tag -v blankfile-signed-tag |
ef5a6fb5 CR |
1019 | ' |
1020 | ||
1021 | printf ' ' >sigblanknonlfile | |
1022 | get_tag_header blanknonlfile-signed-tag $commit commit $time >expect | |
1023 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1024 | test_expect_success GPG \ |
ef5a6fb5 | 1025 | 'creating a signed tag with spaces and no newline should succeed' ' |
d592b315 | 1026 | git tag -s -F sigblanknonlfile blanknonlfile-signed-tag && |
ef5a6fb5 | 1027 | get_tag_msg blanknonlfile-signed-tag >actual && |
3af82863 | 1028 | test_cmp expect actual && |
d592b315 | 1029 | git tag -v signed-tag |
ef5a6fb5 CR |
1030 | ' |
1031 | ||
1032 | # messages with commented lines for signed tags: | |
1033 | ||
1034 | cat >sigcommentsfile <<EOF | |
1035 | # A comment | |
1036 | ||
1037 | ############ | |
1038 | The message. | |
1039 | ############ | |
1040 | One line. | |
1041 | ||
1042 | ||
1043 | # commented lines | |
1044 | # commented lines | |
1045 | ||
1046 | Another line. | |
1047 | # comments | |
1048 | ||
1049 | Last line. | |
1050 | EOF | |
1051 | get_tag_header comments-signed-tag $commit commit $time >expect | |
1052 | cat >>expect <<EOF | |
1053 | The message. | |
1054 | One line. | |
1055 | ||
1056 | Another line. | |
1057 | ||
1058 | Last line. | |
1059 | EOF | |
1060 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1061 | test_expect_success GPG \ |
ef5a6fb5 | 1062 | 'creating a signed tag with a -F file with #comments should succeed' ' |
d592b315 | 1063 | git tag -s -F sigcommentsfile comments-signed-tag && |
ef5a6fb5 | 1064 | get_tag_msg comments-signed-tag >actual && |
3af82863 | 1065 | test_cmp expect actual && |
d592b315 | 1066 | git tag -v comments-signed-tag |
ef5a6fb5 CR |
1067 | ' |
1068 | ||
1069 | get_tag_header comment-signed-tag $commit commit $time >expect | |
1070 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1071 | test_expect_success GPG \ |
ef5a6fb5 | 1072 | 'creating a signed tag with #commented -m message should succeed' ' |
d592b315 | 1073 | git tag -s -m "#comment" comment-signed-tag && |
ef5a6fb5 | 1074 | get_tag_msg comment-signed-tag >actual && |
3af82863 | 1075 | test_cmp expect actual && |
d592b315 | 1076 | git tag -v comment-signed-tag |
ef5a6fb5 CR |
1077 | ' |
1078 | ||
1079 | echo '#comment' >sigcommentfile | |
1080 | echo '' >>sigcommentfile | |
1081 | echo '####' >>sigcommentfile | |
1082 | get_tag_header commentfile-signed-tag $commit commit $time >expect | |
1083 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1084 | test_expect_success GPG \ |
ef5a6fb5 | 1085 | 'creating a signed tag with #commented -F messagefile should succeed' ' |
d592b315 | 1086 | git tag -s -F sigcommentfile commentfile-signed-tag && |
ef5a6fb5 | 1087 | get_tag_msg commentfile-signed-tag >actual && |
3af82863 | 1088 | test_cmp expect actual && |
d592b315 | 1089 | git tag -v commentfile-signed-tag |
ef5a6fb5 CR |
1090 | ' |
1091 | ||
1092 | printf '#comment' >sigcommentnonlfile | |
1093 | get_tag_header commentnonlfile-signed-tag $commit commit $time >expect | |
1094 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1095 | test_expect_success GPG \ |
ef5a6fb5 | 1096 | 'creating a signed tag with a #comment and no newline should succeed' ' |
d592b315 | 1097 | git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag && |
ef5a6fb5 | 1098 | get_tag_msg commentnonlfile-signed-tag >actual && |
3af82863 | 1099 | test_cmp expect actual && |
d592b315 | 1100 | git tag -v commentnonlfile-signed-tag |
ef5a6fb5 CR |
1101 | ' |
1102 | ||
5206d130 CR |
1103 | # listing messages for signed tags: |
1104 | ||
a4df22ce | 1105 | test_expect_success GPG \ |
5206d130 | 1106 | 'listing the one-line message of a signed tag should succeed' ' |
d592b315 | 1107 | git tag -s -m "A message line signed" stag-one-line && |
5206d130 CR |
1108 | |
1109 | echo "stag-one-line" >expect && | |
d592b315 | 1110 | git tag -l | grep "^stag-one-line" >actual && |
3af82863 | 1111 | test_cmp expect actual && |
d592b315 | 1112 | git tag -n0 -l | grep "^stag-one-line" >actual && |
3af82863 | 1113 | test_cmp expect actual && |
d592b315 | 1114 | git tag -n0 -l stag-one-line >actual && |
3af82863 | 1115 | test_cmp expect actual && |
5206d130 CR |
1116 | |
1117 | echo "stag-one-line A message line signed" >expect && | |
d592b315 | 1118 | git tag -n1 -l | grep "^stag-one-line" >actual && |
3af82863 | 1119 | test_cmp expect actual && |
d592b315 | 1120 | git tag -n -l | grep "^stag-one-line" >actual && |
3af82863 | 1121 | test_cmp expect actual && |
d592b315 | 1122 | git tag -n1 -l stag-one-line >actual && |
3af82863 | 1123 | test_cmp expect actual && |
d592b315 | 1124 | git tag -n2 -l stag-one-line >actual && |
3af82863 | 1125 | test_cmp expect actual && |
d592b315 | 1126 | git tag -n999 -l stag-one-line >actual && |
3af82863 | 1127 | test_cmp expect actual |
5206d130 CR |
1128 | ' |
1129 | ||
a4df22ce | 1130 | test_expect_success GPG \ |
5206d130 | 1131 | 'listing the zero-lines message of a signed tag should succeed' ' |
d592b315 | 1132 | git tag -s -m "" stag-zero-lines && |
5206d130 CR |
1133 | |
1134 | echo "stag-zero-lines" >expect && | |
d592b315 | 1135 | git tag -l | grep "^stag-zero-lines" >actual && |
3af82863 | 1136 | test_cmp expect actual && |
d592b315 | 1137 | git tag -n0 -l | grep "^stag-zero-lines" >actual && |
3af82863 | 1138 | test_cmp expect actual && |
d592b315 | 1139 | git tag -n0 -l stag-zero-lines >actual && |
3af82863 | 1140 | test_cmp expect actual && |
5206d130 CR |
1141 | |
1142 | echo "stag-zero-lines " >expect && | |
d592b315 | 1143 | git tag -n1 -l | grep "^stag-zero-lines" >actual && |
3af82863 | 1144 | test_cmp expect actual && |
d592b315 | 1145 | git tag -n -l | grep "^stag-zero-lines" >actual && |
3af82863 | 1146 | test_cmp expect actual && |
d592b315 | 1147 | git tag -n1 -l stag-zero-lines >actual && |
3af82863 | 1148 | test_cmp expect actual && |
d592b315 | 1149 | git tag -n2 -l stag-zero-lines >actual && |
3af82863 | 1150 | test_cmp expect actual && |
d592b315 | 1151 | git tag -n999 -l stag-zero-lines >actual && |
3af82863 | 1152 | test_cmp expect actual |
5206d130 CR |
1153 | ' |
1154 | ||
1155 | echo 'stag line one' >sigtagmsg | |
1156 | echo 'stag line two' >>sigtagmsg | |
1157 | echo 'stag line three' >>sigtagmsg | |
a4df22ce | 1158 | test_expect_success GPG \ |
5206d130 | 1159 | 'listing many message lines of a signed tag should succeed' ' |
d592b315 | 1160 | git tag -s -F sigtagmsg stag-lines && |
5206d130 CR |
1161 | |
1162 | echo "stag-lines" >expect && | |
d592b315 | 1163 | git tag -l | grep "^stag-lines" >actual && |
3af82863 | 1164 | test_cmp expect actual && |
d592b315 | 1165 | git tag -n0 -l | grep "^stag-lines" >actual && |
3af82863 | 1166 | test_cmp expect actual && |
d592b315 | 1167 | git tag -n0 -l stag-lines >actual && |
3af82863 | 1168 | test_cmp expect actual && |
5206d130 CR |
1169 | |
1170 | echo "stag-lines stag line one" >expect && | |
d592b315 | 1171 | git tag -n1 -l | grep "^stag-lines" >actual && |
3af82863 | 1172 | test_cmp expect actual && |
d592b315 | 1173 | git tag -n -l | grep "^stag-lines" >actual && |
3af82863 | 1174 | test_cmp expect actual && |
d592b315 | 1175 | git tag -n1 -l stag-lines >actual && |
3af82863 | 1176 | test_cmp expect actual && |
5206d130 CR |
1177 | |
1178 | echo " stag line two" >>expect && | |
d592b315 | 1179 | git tag -n2 -l | grep "^ *stag.line" >actual && |
3af82863 | 1180 | test_cmp expect actual && |
d592b315 | 1181 | git tag -n2 -l stag-lines >actual && |
3af82863 | 1182 | test_cmp expect actual && |
5206d130 CR |
1183 | |
1184 | echo " stag line three" >>expect && | |
d592b315 | 1185 | git tag -n3 -l | grep "^ *stag.line" >actual && |
3af82863 | 1186 | test_cmp expect actual && |
d592b315 | 1187 | git tag -n3 -l stag-lines >actual && |
3af82863 | 1188 | test_cmp expect actual && |
d592b315 | 1189 | git tag -n4 -l | grep "^ *stag.line" >actual && |
3af82863 | 1190 | test_cmp expect actual && |
d592b315 | 1191 | git tag -n4 -l stag-lines >actual && |
3af82863 | 1192 | test_cmp expect actual && |
d592b315 | 1193 | git tag -n99 -l | grep "^ *stag.line" >actual && |
3af82863 | 1194 | test_cmp expect actual && |
d592b315 | 1195 | git tag -n99 -l stag-lines >actual && |
3af82863 | 1196 | test_cmp expect actual |
5206d130 CR |
1197 | ' |
1198 | ||
ef5a6fb5 CR |
1199 | # tags pointing to objects different from commits: |
1200 | ||
1201 | tree=$(git rev-parse HEAD^{tree}) | |
1202 | blob=$(git rev-parse HEAD:foo) | |
a4df22ce | 1203 | tag=$(git rev-parse signed-tag 2>/dev/null) |
ef5a6fb5 CR |
1204 | |
1205 | get_tag_header tree-signed-tag $tree tree $time >expect | |
1206 | echo "A message for a tree" >>expect | |
1207 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1208 | test_expect_success GPG \ |
ef5a6fb5 | 1209 | 'creating a signed tag pointing to a tree should succeed' ' |
d592b315 | 1210 | git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} && |
ef5a6fb5 | 1211 | get_tag_msg tree-signed-tag >actual && |
3af82863 | 1212 | test_cmp expect actual |
ef5a6fb5 CR |
1213 | ' |
1214 | ||
1215 | get_tag_header blob-signed-tag $blob blob $time >expect | |
1216 | echo "A message for a blob" >>expect | |
1217 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1218 | test_expect_success GPG \ |
ef5a6fb5 | 1219 | 'creating a signed tag pointing to a blob should succeed' ' |
d592b315 | 1220 | git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo && |
ef5a6fb5 | 1221 | get_tag_msg blob-signed-tag >actual && |
3af82863 | 1222 | test_cmp expect actual |
ef5a6fb5 CR |
1223 | ' |
1224 | ||
1225 | get_tag_header tag-signed-tag $tag tag $time >expect | |
1226 | echo "A message for another tag" >>expect | |
1227 | echo '-----BEGIN PGP SIGNATURE-----' >>expect | |
a4df22ce | 1228 | test_expect_success GPG \ |
ef5a6fb5 | 1229 | 'creating a signed tag pointing to another tag should succeed' ' |
d592b315 | 1230 | git tag -s -m "A message for another tag" tag-signed-tag signed-tag && |
ef5a6fb5 | 1231 | get_tag_msg tag-signed-tag >actual && |
3af82863 | 1232 | test_cmp expect actual |
ef5a6fb5 CR |
1233 | ' |
1234 | ||
c8525c30 | 1235 | # usage with rfc1991 signatures |
c8525c30 MG |
1236 | get_tag_header rfc1991-signed-tag $commit commit $time >expect |
1237 | echo "RFC1991 signed tag" >>expect | |
1238 | echo '-----BEGIN PGP MESSAGE-----' >>expect | |
c0e0ed6e | 1239 | test_expect_success GPG,RFC1991 \ |
c8525c30 | 1240 | 'creating a signed tag with rfc1991' ' |
086cb911 | 1241 | echo "rfc1991" >gpghome/gpg.conf && |
c8525c30 MG |
1242 | git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit && |
1243 | get_tag_msg rfc1991-signed-tag >actual && | |
1244 | test_cmp expect actual | |
1245 | ' | |
1246 | ||
1247 | cat >fakeeditor <<'EOF' | |
1248 | #!/bin/sh | |
1249 | cp "$1" actual | |
1250 | EOF | |
1251 | chmod +x fakeeditor | |
1252 | ||
c0e0ed6e | 1253 | test_expect_success GPG,RFC1991 \ |
c8525c30 | 1254 | 'reediting a signed tag body omits signature' ' |
086cb911 | 1255 | echo "rfc1991" >gpghome/gpg.conf && |
c8525c30 MG |
1256 | echo "RFC1991 signed tag" >expect && |
1257 | GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit && | |
1258 | test_cmp expect actual | |
1259 | ' | |
1260 | ||
c0e0ed6e | 1261 | test_expect_success GPG,RFC1991 \ |
c8525c30 | 1262 | 'verifying rfc1991 signature' ' |
086cb911 | 1263 | echo "rfc1991" >gpghome/gpg.conf && |
c8525c30 MG |
1264 | git tag -v rfc1991-signed-tag |
1265 | ' | |
1266 | ||
c0e0ed6e | 1267 | test_expect_success GPG,RFC1991 \ |
c8525c30 | 1268 | 'list tag with rfc1991 signature' ' |
086cb911 | 1269 | echo "rfc1991" >gpghome/gpg.conf && |
c8525c30 MG |
1270 | echo "rfc1991-signed-tag RFC1991 signed tag" >expect && |
1271 | git tag -l -n1 rfc1991-signed-tag >actual && | |
1272 | test_cmp expect actual && | |
1273 | git tag -l -n2 rfc1991-signed-tag >actual && | |
1274 | test_cmp expect actual && | |
1275 | git tag -l -n999 rfc1991-signed-tag >actual && | |
1276 | test_cmp expect actual | |
1277 | ' | |
1278 | ||
1279 | rm -f gpghome/gpg.conf | |
1280 | ||
c0e0ed6e | 1281 | test_expect_success GPG,RFC1991 \ |
c8525c30 MG |
1282 | 'verifying rfc1991 signature without --rfc1991' ' |
1283 | git tag -v rfc1991-signed-tag | |
1284 | ' | |
1285 | ||
c0e0ed6e | 1286 | test_expect_success GPG,RFC1991 \ |
c8525c30 MG |
1287 | 'list tag with rfc1991 signature without --rfc1991' ' |
1288 | echo "rfc1991-signed-tag RFC1991 signed tag" >expect && | |
1289 | git tag -l -n1 rfc1991-signed-tag >actual && | |
1290 | test_cmp expect actual && | |
1291 | git tag -l -n2 rfc1991-signed-tag >actual && | |
1292 | test_cmp expect actual && | |
1293 | git tag -l -n999 rfc1991-signed-tag >actual && | |
1294 | test_cmp expect actual | |
1295 | ' | |
1296 | ||
c0e0ed6e | 1297 | test_expect_success GPG,RFC1991 \ |
c8525c30 MG |
1298 | 'reediting a signed tag body omits signature' ' |
1299 | echo "RFC1991 signed tag" >expect && | |
1300 | GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit && | |
1301 | test_cmp expect actual | |
1302 | ' | |
1303 | ||
aba91192 | 1304 | # try to sign with bad user.signingkey |
a4df22ce | 1305 | test_expect_success GPG \ |
efee9553 | 1306 | 'git tag -s fails if gpg is misconfigured (bad key)' \ |
9ffda48f SG |
1307 | 'test_config user.signingkey BobTheMouse && |
1308 | test_must_fail git tag -s -m tail tag-gpg-failure' | |
aba91192 | 1309 | |
efee9553 MG |
1310 | # try to produce invalid signature |
1311 | test_expect_success GPG \ | |
1312 | 'git tag -s fails if gpg is misconfigured (bad signature format)' \ | |
1313 | 'test_config gpg.program echo && | |
1314 | test_must_fail git tag -s -m tail tag-gpg-failure' | |
1315 | ||
1316 | ||
ef5a6fb5 CR |
1317 | # try to verify without gpg: |
1318 | ||
1319 | rm -rf gpghome | |
a4df22ce | 1320 | test_expect_success GPG \ |
ef5a6fb5 | 1321 | 'verify signed tag fails when public key is not present' \ |
d592b315 | 1322 | 'test_must_fail git tag -v signed-tag' |
ef5a6fb5 | 1323 | |
41ac414e | 1324 | test_expect_success \ |
d592b315 | 1325 | 'git tag -a fails if tag annotation is empty' ' |
41ac414e | 1326 | ! (GIT_EDITOR=cat git tag -a initial-comment) |
eb9d2b91 MH |
1327 | ' |
1328 | ||
4d8b1dc8 MH |
1329 | test_expect_success \ |
1330 | 'message in editor has initial comment' ' | |
5649bd9a ÆAB |
1331 | ! (GIT_EDITOR=cat git tag -a initial-comment > actual) |
1332 | ' | |
1333 | ||
b3e1900a | 1334 | test_expect_success 'message in editor has initial comment: first line' ' |
eb9d2b91 | 1335 | # check the first line --- should be empty |
5649bd9a ÆAB |
1336 | echo >first.expect && |
1337 | sed -e 1q <actual >first.actual && | |
b3e1900a | 1338 | test_i18ncmp first.expect first.actual |
5649bd9a ÆAB |
1339 | ' |
1340 | ||
1341 | test_expect_success \ | |
1342 | 'message in editor has initial comment: remainder' ' | |
eb9d2b91 | 1343 | # remove commented lines from the remainder -- should be empty |
99094a7a | 1344 | >rest.expect && |
11f228b0 | 1345 | sed -e 1d -e "/^#/d" <actual >rest.actual && |
5649bd9a | 1346 | test_cmp rest.expect rest.actual |
4d8b1dc8 MH |
1347 | ' |
1348 | ||
1349 | get_tag_header reuse $commit commit $time >expect | |
1350 | echo "An annotation to be reused" >> expect | |
1351 | test_expect_success \ | |
1352 | 'overwriting an annoted tag should use its previous body' ' | |
1353 | git tag -a -m "An annotation to be reused" reuse && | |
1354 | GIT_EDITOR=true git tag -f -a reuse && | |
1355 | get_tag_msg reuse >actual && | |
3af82863 | 1356 | test_cmp expect actual |
4d8b1dc8 MH |
1357 | ' |
1358 | ||
dbd0f5c7 JH |
1359 | test_expect_success 'filename for the message is relative to cwd' ' |
1360 | mkdir subdir && | |
1361 | echo "Tag message in top directory" >msgfile-5 && | |
1362 | echo "Tag message in sub directory" >subdir/msgfile-5 && | |
1363 | ( | |
1364 | cd subdir && | |
1365 | git tag -a -F msgfile-5 tag-from-subdir | |
1366 | ) && | |
1367 | git cat-file tag tag-from-subdir | grep "in sub directory" | |
1368 | ' | |
1369 | ||
1370 | test_expect_success 'filename for the message is relative to cwd' ' | |
1371 | echo "Tag message in sub directory" >subdir/msgfile-6 && | |
1372 | ( | |
1373 | cd subdir && | |
1374 | git tag -a -F msgfile-6 tag-from-subdir-2 | |
1375 | ) && | |
1376 | git cat-file tag tag-from-subdir-2 | grep "in sub directory" | |
1377 | ' | |
1378 | ||
32c35cfb JG |
1379 | # create a few more commits to test --contains |
1380 | ||
1381 | hash1=$(git rev-parse HEAD) | |
1382 | ||
1383 | test_expect_success 'creating second commit and tag' ' | |
1384 | echo foo-2.0 >foo && | |
1385 | git add foo && | |
2dec68cf | 1386 | git commit -m second && |
32c35cfb JG |
1387 | git tag v2.0 |
1388 | ' | |
1389 | ||
1390 | hash2=$(git rev-parse HEAD) | |
1391 | ||
1392 | test_expect_success 'creating third commit without tag' ' | |
1393 | echo foo-dev >foo && | |
1394 | git add foo && | |
1395 | git commit -m third | |
1396 | ' | |
1397 | ||
1398 | hash3=$(git rev-parse HEAD) | |
1399 | ||
1400 | # simple linear checks of --continue | |
1401 | ||
1402 | cat > expected <<EOF | |
1403 | v0.2.1 | |
1404 | v1.0 | |
1405 | v1.0.1 | |
1406 | v1.1.3 | |
1407 | v2.0 | |
1408 | EOF | |
1409 | ||
1410 | test_expect_success 'checking that first commit is in all tags (hash)' " | |
2dec68cf | 1411 | git tag -l --contains $hash1 v* >actual && |
32c35cfb JG |
1412 | test_cmp expected actual |
1413 | " | |
1414 | ||
1415 | # other ways of specifying the commit | |
1416 | test_expect_success 'checking that first commit is in all tags (tag)' " | |
2dec68cf | 1417 | git tag -l --contains v1.0 v* >actual && |
32c35cfb JG |
1418 | test_cmp expected actual |
1419 | " | |
1420 | ||
1421 | test_expect_success 'checking that first commit is in all tags (relative)' " | |
2dec68cf | 1422 | git tag -l --contains HEAD~2 v* >actual && |
32c35cfb JG |
1423 | test_cmp expected actual |
1424 | " | |
1425 | ||
ac3f5a34 ÆAB |
1426 | # All the --contains tests above, but with --no-contains |
1427 | test_expect_success 'checking that first commit is not listed in any tag with --no-contains (hash)' " | |
1428 | >expected && | |
1429 | git tag -l --no-contains $hash1 v* >actual && | |
1430 | test_cmp expected actual | |
1431 | " | |
1432 | ||
1433 | test_expect_success 'checking that first commit is in all tags (tag)' " | |
1434 | git tag -l --no-contains v1.0 v* >actual && | |
1435 | test_cmp expected actual | |
1436 | " | |
1437 | ||
1438 | test_expect_success 'checking that first commit is in all tags (relative)' " | |
1439 | git tag -l --no-contains HEAD~2 v* >actual && | |
1440 | test_cmp expected actual | |
1441 | " | |
1442 | ||
32c35cfb JG |
1443 | cat > expected <<EOF |
1444 | v2.0 | |
1445 | EOF | |
1446 | ||
1447 | test_expect_success 'checking that second commit only has one tag' " | |
2dec68cf | 1448 | git tag -l --contains $hash2 v* >actual && |
32c35cfb JG |
1449 | test_cmp expected actual |
1450 | " | |
1451 | ||
ac3f5a34 ÆAB |
1452 | cat > expected <<EOF |
1453 | v0.2.1 | |
1454 | v1.0 | |
1455 | v1.0.1 | |
1456 | v1.1.3 | |
1457 | EOF | |
1458 | ||
1459 | test_expect_success 'inverse of the last test, with --no-contains' " | |
1460 | git tag -l --no-contains $hash2 v* >actual && | |
1461 | test_cmp expected actual | |
1462 | " | |
32c35cfb JG |
1463 | |
1464 | cat > expected <<EOF | |
1465 | EOF | |
1466 | ||
1467 | test_expect_success 'checking that third commit has no tags' " | |
2dec68cf | 1468 | git tag -l --contains $hash3 v* >actual && |
32c35cfb JG |
1469 | test_cmp expected actual |
1470 | " | |
1471 | ||
ac3f5a34 ÆAB |
1472 | cat > expected <<EOF |
1473 | v0.2.1 | |
1474 | v1.0 | |
1475 | v1.0.1 | |
1476 | v1.1.3 | |
1477 | v2.0 | |
1478 | EOF | |
1479 | ||
1480 | test_expect_success 'conversely --no-contains on the third commit lists all tags' " | |
1481 | git tag -l --no-contains $hash3 v* >actual && | |
1482 | test_cmp expected actual | |
1483 | " | |
1484 | ||
32c35cfb JG |
1485 | # how about a simple merge? |
1486 | ||
1487 | test_expect_success 'creating simple branch' ' | |
1488 | git branch stable v2.0 && | |
1489 | git checkout stable && | |
1490 | echo foo-3.0 > foo && | |
2dec68cf | 1491 | git commit foo -m fourth && |
32c35cfb JG |
1492 | git tag v3.0 |
1493 | ' | |
1494 | ||
1495 | hash4=$(git rev-parse HEAD) | |
1496 | ||
1497 | cat > expected <<EOF | |
1498 | v3.0 | |
1499 | EOF | |
1500 | ||
1501 | test_expect_success 'checking that branch head only has one tag' " | |
2dec68cf | 1502 | git tag -l --contains $hash4 v* >actual && |
32c35cfb JG |
1503 | test_cmp expected actual |
1504 | " | |
1505 | ||
ac3f5a34 ÆAB |
1506 | cat > expected <<EOF |
1507 | v0.2.1 | |
1508 | v1.0 | |
1509 | v1.0.1 | |
1510 | v1.1.3 | |
1511 | v2.0 | |
1512 | EOF | |
1513 | ||
1514 | test_expect_success 'checking that branch head with --no-contains lists all but one tag' " | |
1515 | git tag -l --no-contains $hash4 v* >actual && | |
1516 | test_cmp expected actual | |
1517 | " | |
1518 | ||
32c35cfb JG |
1519 | test_expect_success 'merging original branch into this branch' ' |
1520 | git merge --strategy=ours master && | |
1521 | git tag v4.0 | |
1522 | ' | |
1523 | ||
1524 | cat > expected <<EOF | |
1525 | v4.0 | |
1526 | EOF | |
1527 | ||
1528 | test_expect_success 'checking that original branch head has one tag now' " | |
2dec68cf | 1529 | git tag -l --contains $hash3 v* >actual && |
32c35cfb JG |
1530 | test_cmp expected actual |
1531 | " | |
1532 | ||
ac3f5a34 ÆAB |
1533 | cat > expected <<EOF |
1534 | v0.2.1 | |
1535 | v1.0 | |
1536 | v1.0.1 | |
1537 | v1.1.3 | |
1538 | v2.0 | |
1539 | v3.0 | |
1540 | EOF | |
1541 | ||
1542 | test_expect_success 'checking that original branch head with --no-contains lists all but one tag now' " | |
1543 | git tag -l --no-contains $hash3 v* >actual && | |
1544 | test_cmp expected actual | |
1545 | " | |
1546 | ||
32c35cfb JG |
1547 | cat > expected <<EOF |
1548 | v0.2.1 | |
1549 | v1.0 | |
1550 | v1.0.1 | |
1551 | v1.1.3 | |
1552 | v2.0 | |
1553 | v3.0 | |
1554 | v4.0 | |
1555 | EOF | |
1556 | ||
1557 | test_expect_success 'checking that initial commit is in all tags' " | |
2dec68cf | 1558 | git tag -l --contains $hash1 v* >actual && |
32c35cfb JG |
1559 | test_cmp expected actual |
1560 | " | |
1561 | ||
6a338149 ÆAB |
1562 | test_expect_success 'checking that --contains can be used in non-list mode' ' |
1563 | git tag --contains $hash1 v* >actual && | |
1564 | test_cmp expected actual | |
1565 | ' | |
1566 | ||
ac3f5a34 ÆAB |
1567 | test_expect_success 'checking that initial commit is in all tags with --no-contains' " |
1568 | >expected && | |
1569 | git tag -l --no-contains $hash1 v* >actual && | |
1570 | test_cmp expected actual | |
1571 | " | |
1572 | ||
e0e03a73 ST |
1573 | # mixing modes and options: |
1574 | ||
1575 | test_expect_success 'mixing incompatibles modes and options is forbidden' ' | |
2dec68cf | 1576 | test_must_fail git tag -a && |
bf748049 ÆAB |
1577 | test_must_fail git tag -a -l && |
1578 | test_must_fail git tag -s && | |
1579 | test_must_fail git tag -s -l && | |
1580 | test_must_fail git tag -m && | |
1581 | test_must_fail git tag -m -l && | |
1582 | test_must_fail git tag -m "hlagh" && | |
1583 | test_must_fail git tag -m "hlagh" -l && | |
1584 | test_must_fail git tag -F && | |
1585 | test_must_fail git tag -F -l && | |
1586 | test_must_fail git tag -f && | |
1587 | test_must_fail git tag -f -l && | |
1588 | test_must_fail git tag -a -s -m -F && | |
1589 | test_must_fail git tag -a -s -m -F -l && | |
2dec68cf | 1590 | test_must_fail git tag -l -v && |
bf748049 ÆAB |
1591 | test_must_fail git tag -l -d && |
1592 | test_must_fail git tag -l -v -d && | |
bf748049 | 1593 | test_must_fail git tag -n 100 -v && |
2dec68cf JN |
1594 | test_must_fail git tag -l -m msg && |
1595 | test_must_fail git tag -l -F some file && | |
b643827b ÆAB |
1596 | test_must_fail git tag -v -s && |
1597 | test_must_fail git tag --contains tag-tree && | |
ac3f5a34 ÆAB |
1598 | test_must_fail git tag --contains tag-blob && |
1599 | test_must_fail git tag --no-contains tag-tree && | |
1600 | test_must_fail git tag --no-contains tag-blob && | |
75057691 ÆAB |
1601 | test_must_fail git tag --contains --no-contains && |
1602 | test_must_fail git tag --no-with HEAD && | |
1603 | test_must_fail git tag --no-without HEAD | |
e0e03a73 ST |
1604 | ' |
1605 | ||
75057691 | 1606 | for option in --contains --with --no-contains --without --merged --no-merged --points-at |
6a338149 ÆAB |
1607 | do |
1608 | test_expect_success "mixing incompatible modes with $option is forbidden" " | |
1609 | test_must_fail git tag -d $option HEAD && | |
1610 | test_must_fail git tag -d $option HEAD some-tag && | |
1611 | test_must_fail git tag -v $option HEAD | |
1612 | " | |
1613 | test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" " | |
1614 | git tag -n $option HEAD HEAD && | |
1e0c3b68 ÆAB |
1615 | git tag $option HEAD HEAD && |
1616 | git tag $option | |
6a338149 ÆAB |
1617 | " |
1618 | done | |
e0e03a73 | 1619 | |
ae7706b9 TG |
1620 | # check points-at |
1621 | ||
6a338149 ÆAB |
1622 | test_expect_success '--points-at can be used in non-list mode' ' |
1623 | echo v4.0 >expect && | |
1624 | git tag --points-at=v4.0 "v*" >actual && | |
1625 | test_cmp expect actual | |
ae7706b9 TG |
1626 | ' |
1627 | ||
1e0c3b68 ÆAB |
1628 | test_expect_success '--points-at is a synonym for --points-at HEAD' ' |
1629 | echo v4.0 >expect && | |
1630 | git tag --points-at >actual && | |
1631 | test_cmp expect actual | |
ae7706b9 TG |
1632 | ' |
1633 | ||
1634 | test_expect_success '--points-at finds lightweight tags' ' | |
1635 | echo v4.0 >expect && | |
1636 | git tag --points-at v4.0 >actual && | |
1637 | test_cmp expect actual | |
1638 | ' | |
1639 | ||
1640 | test_expect_success '--points-at finds annotated tags of commits' ' | |
1641 | git tag -m "v4.0, annotated" annotated-v4.0 v4.0 && | |
1642 | echo annotated-v4.0 >expect && | |
1643 | git tag -l --points-at v4.0 "annotated*" >actual && | |
1644 | test_cmp expect actual | |
1645 | ' | |
1646 | ||
1647 | test_expect_success '--points-at finds annotated tags of tags' ' | |
1648 | git tag -m "describing the v4.0 tag object" \ | |
1649 | annotated-again-v4.0 annotated-v4.0 && | |
1650 | cat >expect <<-\EOF && | |
1651 | annotated-again-v4.0 | |
1652 | annotated-v4.0 | |
1653 | EOF | |
1654 | git tag --points-at=annotated-v4.0 >actual && | |
1655 | test_cmp expect actual | |
1656 | ' | |
1657 | ||
1658 | test_expect_success 'multiple --points-at are OR-ed together' ' | |
1659 | cat >expect <<-\EOF && | |
1660 | v2.0 | |
1661 | v3.0 | |
1662 | EOF | |
1663 | git tag --points-at=v2.0 --points-at=v3.0 >actual && | |
1664 | test_cmp expect actual | |
1665 | ' | |
1666 | ||
9ef176b5 NTND |
1667 | test_expect_success 'lexical sort' ' |
1668 | git tag foo1.3 && | |
1669 | git tag foo1.6 && | |
1670 | git tag foo1.10 && | |
1671 | git tag -l --sort=refname "foo*" >actual && | |
dc662d44 JK |
1672 | cat >expect <<-\EOF && |
1673 | foo1.10 | |
1674 | foo1.3 | |
1675 | foo1.6 | |
1676 | EOF | |
9ef176b5 NTND |
1677 | test_cmp expect actual |
1678 | ' | |
1679 | ||
1680 | test_expect_success 'version sort' ' | |
1681 | git tag -l --sort=version:refname "foo*" >actual && | |
dc662d44 JK |
1682 | cat >expect <<-\EOF && |
1683 | foo1.3 | |
1684 | foo1.6 | |
1685 | foo1.10 | |
1686 | EOF | |
9ef176b5 NTND |
1687 | test_cmp expect actual |
1688 | ' | |
1689 | ||
1690 | test_expect_success 'reverse version sort' ' | |
1691 | git tag -l --sort=-version:refname "foo*" >actual && | |
dc662d44 JK |
1692 | cat >expect <<-\EOF && |
1693 | foo1.10 | |
1694 | foo1.6 | |
1695 | foo1.3 | |
1696 | EOF | |
9ef176b5 NTND |
1697 | test_cmp expect actual |
1698 | ' | |
1699 | ||
1700 | test_expect_success 'reverse lexical sort' ' | |
1701 | git tag -l --sort=-refname "foo*" >actual && | |
dc662d44 JK |
1702 | cat >expect <<-\EOF && |
1703 | foo1.6 | |
1704 | foo1.3 | |
1705 | foo1.10 | |
1706 | EOF | |
9ef176b5 NTND |
1707 | test_cmp expect actual |
1708 | ' | |
1709 | ||
b150794d | 1710 | test_expect_success 'configured lexical sort' ' |
9ffda48f | 1711 | test_config tag.sort "v:refname" && |
b150794d JK |
1712 | git tag -l "foo*" >actual && |
1713 | cat >expect <<-\EOF && | |
1714 | foo1.3 | |
1715 | foo1.6 | |
1716 | foo1.10 | |
1717 | EOF | |
1718 | test_cmp expect actual | |
1719 | ' | |
1720 | ||
1721 | test_expect_success 'option override configured sort' ' | |
9ffda48f | 1722 | test_config tag.sort "v:refname" && |
b150794d JK |
1723 | git tag -l --sort=-refname "foo*" >actual && |
1724 | cat >expect <<-\EOF && | |
1725 | foo1.6 | |
1726 | foo1.3 | |
1727 | foo1.10 | |
1728 | EOF | |
1729 | test_cmp expect actual | |
1730 | ' | |
1731 | ||
1732 | test_expect_success 'invalid sort parameter on command line' ' | |
1733 | test_must_fail git tag -l --sort=notvalid "foo*" >actual | |
1734 | ' | |
1735 | ||
1736 | test_expect_success 'invalid sort parameter in configuratoin' ' | |
9ffda48f | 1737 | test_config tag.sort "v:notvalid" && |
b7cc53e9 | 1738 | test_must_fail git tag -l "foo*" |
b150794d JK |
1739 | ' |
1740 | ||
d811c8e1 | 1741 | test_expect_success 'version sort with prerelease reordering' ' |
9ffda48f | 1742 | test_config versionsort.prereleaseSuffix -rc && |
d811c8e1 NTND |
1743 | git tag foo1.6-rc1 && |
1744 | git tag foo1.6-rc2 && | |
1745 | git tag -l --sort=version:refname "foo*" >actual && | |
1746 | cat >expect <<-\EOF && | |
1747 | foo1.3 | |
1748 | foo1.6-rc1 | |
1749 | foo1.6-rc2 | |
1750 | foo1.6 | |
1751 | foo1.10 | |
1752 | EOF | |
1753 | test_cmp expect actual | |
1754 | ' | |
1755 | ||
1756 | test_expect_success 'reverse version sort with prerelease reordering' ' | |
9ffda48f | 1757 | test_config versionsort.prereleaseSuffix -rc && |
d811c8e1 NTND |
1758 | git tag -l --sort=-version:refname "foo*" >actual && |
1759 | cat >expect <<-\EOF && | |
1760 | foo1.10 | |
1761 | foo1.6 | |
1762 | foo1.6-rc2 | |
1763 | foo1.6-rc1 | |
1764 | foo1.3 | |
1765 | EOF | |
1766 | test_cmp expect actual | |
1767 | ' | |
1768 | ||
b8231660 | 1769 | test_expect_success 'version sort with prerelease reordering and common leading character' ' |
0c1b4878 SG |
1770 | test_config versionsort.prereleaseSuffix -before && |
1771 | git tag foo1.7-before1 && | |
1772 | git tag foo1.7 && | |
1773 | git tag foo1.7-after1 && | |
1774 | git tag -l --sort=version:refname "foo1.7*" >actual && | |
1775 | cat >expect <<-\EOF && | |
1776 | foo1.7-before1 | |
1777 | foo1.7 | |
1778 | foo1.7-after1 | |
1779 | EOF | |
1780 | test_cmp expect actual | |
1781 | ' | |
1782 | ||
b8231660 | 1783 | test_expect_success 'version sort with prerelease reordering, multiple suffixes and common leading character' ' |
0c1b4878 SG |
1784 | test_config versionsort.prereleaseSuffix -before && |
1785 | git config --add versionsort.prereleaseSuffix -after && | |
1786 | git tag -l --sort=version:refname "foo1.7*" >actual && | |
1787 | cat >expect <<-\EOF && | |
1788 | foo1.7-before1 | |
1789 | foo1.7-after1 | |
1790 | foo1.7 | |
1791 | EOF | |
1792 | test_cmp expect actual | |
1793 | ' | |
1794 | ||
51acfa9d SG |
1795 | test_expect_success 'version sort with prerelease reordering, multiple suffixes match the same tag' ' |
1796 | test_config versionsort.prereleaseSuffix -bar && | |
1797 | git config --add versionsort.prereleaseSuffix -foo-baz && | |
1798 | git config --add versionsort.prereleaseSuffix -foo-bar && | |
1799 | git tag foo1.8-foo-bar && | |
1800 | git tag foo1.8-foo-baz && | |
1801 | git tag foo1.8 && | |
1802 | git tag -l --sort=version:refname "foo1.8*" >actual && | |
1803 | cat >expect <<-\EOF && | |
1804 | foo1.8-foo-baz | |
1805 | foo1.8-foo-bar | |
1806 | foo1.8 | |
1807 | EOF | |
1808 | test_cmp expect actual | |
1809 | ' | |
1810 | ||
1811 | test_expect_success 'version sort with prerelease reordering, multiple suffixes match starting at the same position' ' | |
1812 | test_config versionsort.prereleaseSuffix -pre && | |
1813 | git config --add versionsort.prereleaseSuffix -prerelease && | |
1814 | git tag foo1.9-pre1 && | |
1815 | git tag foo1.9-pre2 && | |
1816 | git tag foo1.9-prerelease1 && | |
1817 | git tag -l --sort=version:refname "foo1.9*" >actual && | |
1818 | cat >expect <<-\EOF && | |
1819 | foo1.9-pre1 | |
1820 | foo1.9-pre2 | |
1821 | foo1.9-prerelease1 | |
1822 | EOF | |
1823 | test_cmp expect actual | |
1824 | ' | |
1825 | ||
c026557a SG |
1826 | test_expect_success 'version sort with general suffix reordering' ' |
1827 | test_config versionsort.suffix -alpha && | |
1828 | git config --add versionsort.suffix -beta && | |
1829 | git config --add versionsort.suffix "" && | |
1830 | git config --add versionsort.suffix -gamma && | |
1831 | git config --add versionsort.suffix -delta && | |
1832 | git tag foo1.10-alpha && | |
1833 | git tag foo1.10-beta && | |
1834 | git tag foo1.10-gamma && | |
1835 | git tag foo1.10-delta && | |
1836 | git tag foo1.10-unlisted-suffix && | |
1837 | git tag -l --sort=version:refname "foo1.10*" >actual && | |
1838 | cat >expect <<-\EOF && | |
1839 | foo1.10-alpha | |
1840 | foo1.10-beta | |
1841 | foo1.10 | |
1842 | foo1.10-unlisted-suffix | |
1843 | foo1.10-gamma | |
1844 | foo1.10-delta | |
1845 | EOF | |
1846 | test_cmp expect actual | |
1847 | ' | |
1848 | ||
1849 | test_expect_success 'versionsort.suffix overrides versionsort.prereleaseSuffix' ' | |
1850 | test_config versionsort.suffix -before && | |
1851 | test_config versionsort.prereleaseSuffix -after && | |
1852 | git tag -l --sort=version:refname "foo1.7*" >actual && | |
1853 | cat >expect <<-\EOF && | |
1854 | foo1.7-before1 | |
1855 | foo1.7 | |
1856 | foo1.7-after1 | |
1857 | EOF | |
1858 | test_cmp expect actual | |
1859 | ' | |
1860 | ||
b8231660 SG |
1861 | test_expect_success 'version sort with very long prerelease suffix' ' |
1862 | test_config versionsort.prereleaseSuffix -very-looooooooooooooooooooooooong-prerelease-suffix && | |
1863 | git tag -l --sort=version:refname | |
1864 | ' | |
1865 | ||
ac3f5a34 | 1866 | test_expect_success ULIMIT_STACK_SIZE '--contains and --no-contains work in a deep repo' ' |
cbc60b67 JJL |
1867 | >expect && |
1868 | i=1 && | |
b9a19078 | 1869 | while test $i -lt 8000 |
cbc60b67 JJL |
1870 | do |
1871 | echo "commit refs/heads/master | |
1872 | committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200 | |
1873 | data <<EOF | |
1874 | commit #$i | |
1875 | EOF" | |
1876 | test $i = 1 && echo "from refs/heads/master^0" | |
1877 | i=$(($i + 1)) | |
1878 | done | git fast-import && | |
1879 | git checkout master && | |
1880 | git tag far-far-away HEAD^ && | |
1881 | run_with_limited_stack git tag --contains HEAD >actual && | |
ac3f5a34 ÆAB |
1882 | test_cmp expect actual && |
1883 | run_with_limited_stack git tag --no-contains HEAD >actual && | |
dff28133 | 1884 | test_line_count "-gt" 10 actual |
cbc60b67 JJL |
1885 | ' |
1886 | ||
df094741 KN |
1887 | test_expect_success '--format should list tags as per format given' ' |
1888 | cat >expect <<-\EOF && | |
0c1b4878 SG |
1889 | refname : refs/tags/v1.0 |
1890 | refname : refs/tags/v1.0.1 | |
1891 | refname : refs/tags/v1.1.3 | |
df094741 | 1892 | EOF |
0c1b4878 | 1893 | git tag -l --format="refname : %(refname)" "v1*" >actual && |
df094741 KN |
1894 | test_cmp expect actual |
1895 | ' | |
1896 | ||
11b087ad JK |
1897 | test_expect_success "set up color tests" ' |
1898 | echo "<RED>v1.0<RESET>" >expect.color && | |
1899 | echo "v1.0" >expect.bare && | |
1900 | color_args="--format=%(color:red)%(refname:short) --list v1.0" | |
1901 | ' | |
1902 | ||
1903 | test_expect_success '%(color) omitted without tty' ' | |
1904 | TERM=vt100 git tag $color_args >actual.raw && | |
1905 | test_decode_color <actual.raw >actual && | |
1906 | test_cmp expect.bare actual | |
1907 | ' | |
1908 | ||
1909 | test_expect_success TTY '%(color) present with tty' ' | |
e433749d | 1910 | test_terminal git tag $color_args >actual.raw && |
11b087ad JK |
1911 | test_decode_color <actual.raw >actual && |
1912 | test_cmp expect.color actual | |
1913 | ' | |
1914 | ||
0c88bf50 JK |
1915 | test_expect_success '--color overrides auto-color' ' |
1916 | git tag --color $color_args >actual.raw && | |
11b087ad JK |
1917 | test_decode_color <actual.raw >actual && |
1918 | test_cmp expect.color actual | |
1919 | ' | |
1920 | ||
b521fd12 JK |
1921 | test_expect_success 'color.ui=always overrides auto-color' ' |
1922 | git -c color.ui=always tag $color_args >actual.raw && | |
1923 | test_decode_color <actual.raw >actual && | |
1924 | test_cmp expect.color actual | |
1925 | ' | |
1926 | ||
5242860f KN |
1927 | test_expect_success 'setup --merged test tags' ' |
1928 | git tag mergetest-1 HEAD~2 && | |
1929 | git tag mergetest-2 HEAD~1 && | |
1930 | git tag mergetest-3 HEAD | |
1931 | ' | |
1932 | ||
6a338149 ÆAB |
1933 | test_expect_success '--merged can be used in non-list mode' ' |
1934 | cat >expect <<-\EOF && | |
1935 | mergetest-1 | |
1936 | mergetest-2 | |
1937 | EOF | |
1938 | git tag --merged=mergetest-2 "mergetest*" >actual && | |
1939 | test_cmp expect actual | |
5242860f KN |
1940 | ' |
1941 | ||
17d6c744 ÆAB |
1942 | test_expect_success '--merged is incompatible with --no-merged' ' |
1943 | test_must_fail git tag --merged HEAD --no-merged HEAD | |
5242860f KN |
1944 | ' |
1945 | ||
1946 | test_expect_success '--merged shows merged tags' ' | |
1947 | cat >expect <<-\EOF && | |
1948 | mergetest-1 | |
1949 | mergetest-2 | |
1950 | EOF | |
1951 | git tag -l --merged=mergetest-2 mergetest-* >actual && | |
1952 | test_cmp expect actual | |
1953 | ' | |
1954 | ||
1955 | test_expect_success '--no-merged show unmerged tags' ' | |
1956 | cat >expect <<-\EOF && | |
1957 | mergetest-3 | |
1958 | EOF | |
1959 | git tag -l --no-merged=mergetest-2 mergetest-* >actual && | |
1960 | test_cmp expect actual | |
1961 | ' | |
1962 | ||
6a338149 ÆAB |
1963 | test_expect_success '--no-merged can be used in non-list mode' ' |
1964 | git tag --no-merged=mergetest-2 mergetest-* >actual && | |
1965 | test_cmp expect actual | |
1966 | ' | |
1967 | ||
0571979b JK |
1968 | test_expect_success 'ambiguous branch/tags not marked' ' |
1969 | git tag ambiguous && | |
1970 | git branch ambiguous && | |
1971 | echo ambiguous >expect && | |
1972 | git tag -l ambiguous >actual && | |
1973 | test_cmp expect actual | |
1974 | ' | |
1975 | ||
ac3f5a34 ÆAB |
1976 | test_expect_success '--contains combined with --no-contains' ' |
1977 | ( | |
1978 | git init no-contains && | |
1979 | cd no-contains && | |
1980 | test_commit v0.1 && | |
1981 | test_commit v0.2 && | |
1982 | test_commit v0.3 && | |
1983 | test_commit v0.4 && | |
1984 | test_commit v0.5 && | |
1985 | cat >expected <<-\EOF && | |
1986 | v0.2 | |
1987 | v0.3 | |
1988 | v0.4 | |
1989 | EOF | |
1990 | git tag --contains v0.2 --no-contains v0.5 >actual && | |
1991 | test_cmp expected actual | |
1992 | ) | |
1993 | ' | |
1994 | ||
1995 | # As the docs say, list tags which contain a specified *commit*. We | |
1996 | # don't recurse down to tags for trees or blobs pointed to by *those* | |
1997 | # commits. | |
1998 | test_expect_success 'Does --[no-]contains stop at commits? Yes!' ' | |
1999 | cd no-contains && | |
2000 | blob=$(git rev-parse v0.3:v0.3.t) && | |
2001 | tree=$(git rev-parse v0.3^{tree}) && | |
2002 | git tag tag-blob $blob && | |
2003 | git tag tag-tree $tree && | |
2004 | git tag --contains v0.3 >actual && | |
2005 | cat >expected <<-\EOF && | |
2006 | v0.3 | |
2007 | v0.4 | |
2008 | v0.5 | |
2009 | EOF | |
2010 | test_cmp expected actual && | |
2011 | git tag --no-contains v0.3 >actual && | |
2012 | cat >expected <<-\EOF && | |
2013 | v0.1 | |
2014 | v0.2 | |
2015 | EOF | |
2016 | test_cmp expected actual | |
2017 | ' | |
2018 | ||
ef5a6fb5 | 2019 | test_done |