]>
Commit | Line | Data |
---|---|---|
96b2d4fa AP |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Andy Parkins | |
4 | # | |
5 | ||
6 | test_description='for-each-ref test' | |
7 | ||
8 | . ./test-lib.sh | |
e2b23972 | 9 | . "$TEST_DIRECTORY"/lib-gpg.sh |
96b2d4fa AP |
10 | |
11 | # Mon Jul 3 15:18:43 2006 +0000 | |
12 | datestamp=1151939923 | |
13 | setdate_and_increment () { | |
14 | GIT_COMMITTER_DATE="$datestamp +0200" | |
15 | datestamp=$(expr "$datestamp" + 1) | |
16 | GIT_AUTHOR_DATE="$datestamp +0200" | |
17 | datestamp=$(expr "$datestamp" + 1) | |
18 | export GIT_COMMITTER_DATE GIT_AUTHOR_DATE | |
19 | } | |
20 | ||
bc147968 | 21 | test_expect_success setup ' |
96b2d4fa AP |
22 | setdate_and_increment && |
23 | echo "Using $datestamp" > one && | |
24 | git add one && | |
25 | git commit -m "Initial" && | |
26 | setdate_and_increment && | |
bc147968 | 27 | git tag -a -m "Tagging at $datestamp" testtag && |
8cae19d9 JK |
28 | git update-ref refs/remotes/origin/master master && |
29 | git remote add origin nowhere && | |
30 | git config branch.master.remote origin && | |
29bc8850 JK |
31 | git config branch.master.merge refs/heads/master && |
32 | git remote add myfork elsewhere && | |
33 | git config remote.pushdefault myfork && | |
34 | git config push.default current | |
8cae19d9 JK |
35 | ' |
36 | ||
d2bf48d2 JK |
37 | test_atom() { |
38 | case "$1" in | |
39 | head) ref=refs/heads/master ;; | |
40 | tag) ref=refs/tags/testtag ;; | |
7140c22c | 41 | *) ref=$1 ;; |
d2bf48d2 JK |
42 | esac |
43 | printf '%s\n' "$3" >expected | |
e2b23972 | 44 | test_expect_${4:-success} $PREREQ "basic atom: $1 $2" " |
d2bf48d2 | 45 | git for-each-ref --format='%($2)' $ref >actual && |
e2b23972 MG |
46 | sanitize_pgp <actual >actual.clean && |
47 | test_cmp expected actual.clean | |
d2bf48d2 JK |
48 | " |
49 | } | |
50 | ||
51 | test_atom head refname refs/heads/master | |
8cae19d9 | 52 | test_atom head upstream refs/remotes/origin/master |
29bc8850 | 53 | test_atom head push refs/remotes/myfork/master |
d2bf48d2 JK |
54 | test_atom head objecttype commit |
55 | test_atom head objectsize 171 | |
189a5467 RR |
56 | test_atom head objectname $(git rev-parse refs/heads/master) |
57 | test_atom head tree $(git rev-parse refs/heads/master^{tree}) | |
d2bf48d2 JK |
58 | test_atom head parent '' |
59 | test_atom head numparent 0 | |
60 | test_atom head object '' | |
61 | test_atom head type '' | |
b74cf648 JK |
62 | test_atom head '*objectname' '' |
63 | test_atom head '*objecttype' '' | |
d2bf48d2 JK |
64 | test_atom head author 'A U Thor <author@example.com> 1151939924 +0200' |
65 | test_atom head authorname 'A U Thor' | |
66 | test_atom head authoremail '<author@example.com>' | |
67 | test_atom head authordate 'Mon Jul 3 17:18:44 2006 +0200' | |
68 | test_atom head committer 'C O Mitter <committer@example.com> 1151939923 +0200' | |
69 | test_atom head committername 'C O Mitter' | |
70 | test_atom head committeremail '<committer@example.com>' | |
71 | test_atom head committerdate 'Mon Jul 3 17:18:43 2006 +0200' | |
72 | test_atom head tag '' | |
73 | test_atom head tagger '' | |
74 | test_atom head taggername '' | |
75 | test_atom head taggeremail '' | |
76 | test_atom head taggerdate '' | |
77 | test_atom head creator 'C O Mitter <committer@example.com> 1151939923 +0200' | |
78 | test_atom head creatordate 'Mon Jul 3 17:18:43 2006 +0200' | |
79 | test_atom head subject 'Initial' | |
e2b23972 | 80 | test_atom head contents:subject 'Initial' |
d2bf48d2 | 81 | test_atom head body '' |
e2b23972 MG |
82 | test_atom head contents:body '' |
83 | test_atom head contents:signature '' | |
d2bf48d2 JK |
84 | test_atom head contents 'Initial |
85 | ' | |
7a48b832 | 86 | test_atom head HEAD '*' |
d2bf48d2 JK |
87 | |
88 | test_atom tag refname refs/tags/testtag | |
8cae19d9 | 89 | test_atom tag upstream '' |
29bc8850 | 90 | test_atom tag push '' |
d2bf48d2 JK |
91 | test_atom tag objecttype tag |
92 | test_atom tag objectsize 154 | |
189a5467 | 93 | test_atom tag objectname $(git rev-parse refs/tags/testtag) |
d2bf48d2 JK |
94 | test_atom tag tree '' |
95 | test_atom tag parent '' | |
96 | test_atom tag numparent '' | |
189a5467 | 97 | test_atom tag object $(git rev-parse refs/tags/testtag^0) |
d2bf48d2 | 98 | test_atom tag type 'commit' |
b74cf648 JK |
99 | test_atom tag '*objectname' '67a36f10722846e891fbada1ba48ed035de75581' |
100 | test_atom tag '*objecttype' 'commit' | |
d2bf48d2 JK |
101 | test_atom tag author '' |
102 | test_atom tag authorname '' | |
103 | test_atom tag authoremail '' | |
104 | test_atom tag authordate '' | |
105 | test_atom tag committer '' | |
106 | test_atom tag committername '' | |
107 | test_atom tag committeremail '' | |
108 | test_atom tag committerdate '' | |
109 | test_atom tag tag 'testtag' | |
110 | test_atom tag tagger 'C O Mitter <committer@example.com> 1151939925 +0200' | |
111 | test_atom tag taggername 'C O Mitter' | |
112 | test_atom tag taggeremail '<committer@example.com>' | |
113 | test_atom tag taggerdate 'Mon Jul 3 17:18:45 2006 +0200' | |
114 | test_atom tag creator 'C O Mitter <committer@example.com> 1151939925 +0200' | |
115 | test_atom tag creatordate 'Mon Jul 3 17:18:45 2006 +0200' | |
116 | test_atom tag subject 'Tagging at 1151939927' | |
e2b23972 | 117 | test_atom tag contents:subject 'Tagging at 1151939927' |
d2bf48d2 | 118 | test_atom tag body '' |
e2b23972 MG |
119 | test_atom tag contents:body '' |
120 | test_atom tag contents:signature '' | |
d2bf48d2 | 121 | test_atom tag contents 'Tagging at 1151939927 |
96b2d4fa | 122 | ' |
7a48b832 | 123 | test_atom tag HEAD ' ' |
96b2d4fa | 124 | |
41ac414e | 125 | test_expect_success 'Check invalid atoms names are errors' ' |
3604e7c5 | 126 | test_must_fail git for-each-ref --format="%(INVALID)" refs/heads |
96b2d4fa AP |
127 | ' |
128 | ||
129 | test_expect_success 'Check format specifiers are ignored in naming date atoms' ' | |
3604e7c5 NS |
130 | git for-each-ref --format="%(authordate)" refs/heads && |
131 | git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads && | |
132 | git for-each-ref --format="%(authordate) %(authordate:default)" refs/heads && | |
133 | git for-each-ref --format="%(authordate:default) %(authordate:default)" refs/heads | |
96b2d4fa AP |
134 | ' |
135 | ||
136 | test_expect_success 'Check valid format specifiers for date fields' ' | |
3604e7c5 NS |
137 | git for-each-ref --format="%(authordate:default)" refs/heads && |
138 | git for-each-ref --format="%(authordate:relative)" refs/heads && | |
139 | git for-each-ref --format="%(authordate:short)" refs/heads && | |
140 | git for-each-ref --format="%(authordate:local)" refs/heads && | |
141 | git for-each-ref --format="%(authordate:iso8601)" refs/heads && | |
142 | git for-each-ref --format="%(authordate:rfc2822)" refs/heads | |
96b2d4fa AP |
143 | ' |
144 | ||
41ac414e | 145 | test_expect_success 'Check invalid format specifiers are errors' ' |
3604e7c5 | 146 | test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads |
96b2d4fa AP |
147 | ' |
148 | ||
149 | cat >expected <<\EOF | |
150 | 'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200' | |
151 | 'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200' | |
152 | EOF | |
153 | ||
154 | test_expect_success 'Check unformatted date fields output' ' | |
155 | (git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads && | |
156 | git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual && | |
3af82863 | 157 | test_cmp expected actual |
96b2d4fa AP |
158 | ' |
159 | ||
160 | test_expect_success 'Check format "default" formatted date fields output' ' | |
161 | f=default && | |
162 | (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && | |
163 | git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && | |
3af82863 | 164 | test_cmp expected actual |
96b2d4fa AP |
165 | ' |
166 | ||
167 | # Don't know how to do relative check because I can't know when this script | |
168 | # is going to be run and can't fake the current time to git, and hence can't | |
169 | # provide expected output. Instead, I'll just make sure that "relative" | |
170 | # doesn't exit in error | |
171 | # | |
172 | #cat >expected <<\EOF | |
173 | # | |
174 | #EOF | |
175 | # | |
176 | test_expect_success 'Check format "relative" date fields output' ' | |
177 | f=relative && | |
178 | (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && | |
179 | git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual | |
180 | ' | |
181 | ||
182 | cat >expected <<\EOF | |
183 | 'refs/heads/master' '2006-07-03' '2006-07-03' | |
184 | 'refs/tags/testtag' '2006-07-03' | |
185 | EOF | |
186 | ||
187 | test_expect_success 'Check format "short" date fields output' ' | |
188 | f=short && | |
189 | (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && | |
190 | git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && | |
3af82863 | 191 | test_cmp expected actual |
96b2d4fa AP |
192 | ' |
193 | ||
194 | cat >expected <<\EOF | |
195 | 'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006' | |
196 | 'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006' | |
197 | EOF | |
198 | ||
199 | test_expect_success 'Check format "local" date fields output' ' | |
200 | f=local && | |
201 | (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && | |
202 | git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && | |
3af82863 | 203 | test_cmp expected actual |
96b2d4fa AP |
204 | ' |
205 | ||
206 | cat >expected <<\EOF | |
207 | 'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200' | |
208 | 'refs/tags/testtag' '2006-07-03 17:18:45 +0200' | |
209 | EOF | |
210 | ||
211 | test_expect_success 'Check format "iso8601" date fields output' ' | |
212 | f=iso8601 && | |
213 | (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && | |
214 | git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && | |
3af82863 | 215 | test_cmp expected actual |
96b2d4fa AP |
216 | ' |
217 | ||
218 | cat >expected <<\EOF | |
219 | 'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200' | |
220 | 'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200' | |
221 | EOF | |
222 | ||
223 | test_expect_success 'Check format "rfc2822" date fields output' ' | |
224 | f=rfc2822 && | |
225 | (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && | |
226 | git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && | |
3af82863 | 227 | test_cmp expected actual |
96b2d4fa AP |
228 | ' |
229 | ||
aa1462cc JK |
230 | test_expect_success 'Check format of strftime date fields' ' |
231 | echo "my date is 2006-07-03" >expected && | |
232 | git for-each-ref \ | |
233 | --format="%(authordate:format:my date is %Y-%m-%d)" \ | |
234 | refs/heads >actual && | |
235 | test_cmp expected actual | |
236 | ' | |
237 | ||
c899a57c LH |
238 | cat >expected <<\EOF |
239 | refs/heads/master | |
8cae19d9 | 240 | refs/remotes/origin/master |
c899a57c LH |
241 | refs/tags/testtag |
242 | EOF | |
243 | ||
244 | test_expect_success 'Verify ascending sort' ' | |
3604e7c5 | 245 | git for-each-ref --format="%(refname)" --sort=refname >actual && |
3af82863 | 246 | test_cmp expected actual |
c899a57c LH |
247 | ' |
248 | ||
249 | ||
250 | cat >expected <<\EOF | |
251 | refs/tags/testtag | |
8cae19d9 | 252 | refs/remotes/origin/master |
c899a57c LH |
253 | refs/heads/master |
254 | EOF | |
255 | ||
256 | test_expect_success 'Verify descending sort' ' | |
3604e7c5 | 257 | git for-each-ref --format="%(refname)" --sort=-refname >actual && |
3af82863 | 258 | test_cmp expected actual |
c899a57c LH |
259 | ' |
260 | ||
c9ecf4f1 JS |
261 | cat >expected <<\EOF |
262 | 'refs/heads/master' | |
8cae19d9 | 263 | 'refs/remotes/origin/master' |
c9ecf4f1 JS |
264 | 'refs/tags/testtag' |
265 | EOF | |
266 | ||
267 | test_expect_success 'Quoting style: shell' ' | |
268 | git for-each-ref --shell --format="%(refname)" >actual && | |
3af82863 | 269 | test_cmp expected actual |
c9ecf4f1 JS |
270 | ' |
271 | ||
272 | test_expect_success 'Quoting style: perl' ' | |
273 | git for-each-ref --perl --format="%(refname)" >actual && | |
3af82863 | 274 | test_cmp expected actual |
c9ecf4f1 JS |
275 | ' |
276 | ||
277 | test_expect_success 'Quoting style: python' ' | |
278 | git for-each-ref --python --format="%(refname)" >actual && | |
3af82863 | 279 | test_cmp expected actual |
c9ecf4f1 JS |
280 | ' |
281 | ||
282 | cat >expected <<\EOF | |
283 | "refs/heads/master" | |
8cae19d9 | 284 | "refs/remotes/origin/master" |
c9ecf4f1 JS |
285 | "refs/tags/testtag" |
286 | EOF | |
287 | ||
288 | test_expect_success 'Quoting style: tcl' ' | |
289 | git for-each-ref --tcl --format="%(refname)" >actual && | |
3af82863 | 290 | test_cmp expected actual |
c9ecf4f1 JS |
291 | ' |
292 | ||
293 | for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do | |
294 | test_expect_success "more than one quoting style: $i" " | |
295 | git for-each-ref $i 2>&1 | (read line && | |
296 | case \$line in | |
297 | \"error: more than one quoting style\"*) : happy;; | |
298 | *) false | |
299 | esac) | |
300 | " | |
301 | done | |
c899a57c | 302 | |
7d66f21a BW |
303 | cat >expected <<\EOF |
304 | master | |
305 | testtag | |
306 | EOF | |
307 | ||
308 | test_expect_success 'Check short refname format' ' | |
309 | (git for-each-ref --format="%(refname:short)" refs/heads && | |
310 | git for-each-ref --format="%(refname:short)" refs/tags) >actual && | |
311 | test_cmp expected actual | |
312 | ' | |
313 | ||
8cae19d9 JK |
314 | cat >expected <<EOF |
315 | origin/master | |
316 | EOF | |
317 | ||
318 | test_expect_success 'Check short upstream format' ' | |
319 | git for-each-ref --format="%(upstream:short)" refs/heads >actual && | |
320 | test_cmp expected actual | |
321 | ' | |
322 | ||
b28061ce RR |
323 | test_expect_success 'setup for upstream:track[short]' ' |
324 | test_commit two | |
325 | ' | |
326 | ||
327 | cat >expected <<EOF | |
328 | [ahead 1] | |
329 | EOF | |
330 | ||
331 | test_expect_success 'Check upstream:track format' ' | |
332 | git for-each-ref --format="%(upstream:track)" refs/heads >actual && | |
333 | test_cmp expected actual | |
334 | ' | |
335 | ||
336 | cat >expected <<EOF | |
337 | > | |
338 | EOF | |
339 | ||
340 | test_expect_success 'Check upstream:trackshort format' ' | |
341 | git for-each-ref --format="%(upstream:trackshort)" refs/heads >actual && | |
342 | test_cmp expected actual | |
343 | ' | |
344 | ||
345 | test_expect_success 'Check that :track[short] cannot be used with other atoms' ' | |
346 | test_must_fail git for-each-ref --format="%(refname:track)" 2>/dev/null && | |
347 | test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null | |
348 | ' | |
349 | ||
b6160d95 RKC |
350 | test_expect_success 'Check that :track[short] works when upstream is invalid' ' |
351 | cat >expected <<-\EOF && | |
352 | ||
353 | ||
354 | EOF | |
355 | test_when_finished "git config branch.master.merge refs/heads/master" && | |
356 | git config branch.master.merge refs/heads/does-not-exist && | |
357 | git for-each-ref \ | |
358 | --format="%(upstream:track)$LF%(upstream:trackshort)" \ | |
359 | refs/heads >actual && | |
360 | test_cmp expected actual | |
29bc8850 JK |
361 | ' |
362 | ||
363 | test_expect_success '%(push) supports tracking specifiers, too' ' | |
364 | echo "[ahead 1]" >expected && | |
365 | git for-each-ref --format="%(push:track)" refs/heads >actual && | |
366 | test_cmp expected actual | |
b6160d95 RKC |
367 | ' |
368 | ||
67687fea | 369 | cat >expected <<EOF |
189a5467 | 370 | $(git rev-parse --short HEAD) |
67687fea MG |
371 | EOF |
372 | ||
373 | test_expect_success 'Check short objectname format' ' | |
374 | git for-each-ref --format="%(objectname:short)" refs/heads >actual && | |
375 | test_cmp expected actual | |
376 | ' | |
377 | ||
7d66f21a BW |
378 | test_expect_success 'Check for invalid refname format' ' |
379 | test_must_fail git for-each-ref --format="%(refname:INVALID)" | |
380 | ' | |
381 | ||
fddb74c9 RR |
382 | get_color () |
383 | { | |
384 | git config --get-color no.such.slot "$1" | |
385 | } | |
386 | ||
387 | cat >expected <<EOF | |
388 | $(git rev-parse --short refs/heads/master) $(get_color green)master$(get_color reset) | |
389 | $(git rev-parse --short refs/remotes/origin/master) $(get_color green)origin/master$(get_color reset) | |
390 | $(git rev-parse --short refs/tags/testtag) $(get_color green)testtag$(get_color reset) | |
391 | $(git rev-parse --short refs/tags/two) $(get_color green)two$(get_color reset) | |
392 | EOF | |
393 | ||
394 | test_expect_success 'Check %(color:...) ' ' | |
db64eb65 | 395 | git for-each-ref --format="%(objectname:short) %(color:green)%(refname:short)" >actual && |
fddb74c9 RR |
396 | test_cmp expected actual |
397 | ' | |
398 | ||
7d66f21a BW |
399 | cat >expected <<\EOF |
400 | heads/master | |
2bb98169 | 401 | tags/master |
7d66f21a BW |
402 | EOF |
403 | ||
2bb98169 BW |
404 | test_expect_success 'Check ambiguous head and tag refs (strict)' ' |
405 | git config --bool core.warnambiguousrefs true && | |
7d66f21a BW |
406 | git checkout -b newtag && |
407 | echo "Using $datestamp" > one && | |
408 | git add one && | |
409 | git commit -m "Branch" && | |
410 | setdate_and_increment && | |
411 | git tag -m "Tagging at $datestamp" master && | |
412 | git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual && | |
413 | test_cmp expected actual | |
414 | ' | |
415 | ||
2bb98169 BW |
416 | cat >expected <<\EOF |
417 | heads/master | |
418 | master | |
419 | EOF | |
420 | ||
421 | test_expect_success 'Check ambiguous head and tag refs (loose)' ' | |
422 | git config --bool core.warnambiguousrefs false && | |
423 | git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual && | |
424 | test_cmp expected actual | |
425 | ' | |
426 | ||
7d66f21a BW |
427 | cat >expected <<\EOF |
428 | heads/ambiguous | |
429 | ambiguous | |
430 | EOF | |
431 | ||
2bb98169 | 432 | test_expect_success 'Check ambiguous head and tag refs II (loose)' ' |
7d66f21a BW |
433 | git checkout master && |
434 | git tag ambiguous testtag^0 && | |
435 | git branch ambiguous testtag^0 && | |
436 | git for-each-ref --format "%(refname:short)" refs/heads/ambiguous refs/tags/ambiguous >actual && | |
437 | test_cmp expected actual | |
438 | ' | |
439 | ||
e276c26b JH |
440 | test_expect_success 'an unusual tag with an incomplete line' ' |
441 | ||
442 | git tag -m "bogo" bogo && | |
443 | bogo=$(git cat-file tag bogo) && | |
444 | bogo=$(printf "%s" "$bogo" | git mktag) && | |
445 | git tag -f bogo "$bogo" && | |
446 | git for-each-ref --format "%(body)" refs/tags/bogo | |
447 | ||
448 | ' | |
449 | ||
7140c22c JK |
450 | test_expect_success 'create tag with subject and body content' ' |
451 | cat >>msg <<-\EOF && | |
452 | the subject line | |
453 | ||
454 | first body line | |
455 | second body line | |
456 | EOF | |
457 | git tag -F msg subject-body | |
458 | ' | |
459 | test_atom refs/tags/subject-body subject 'the subject line' | |
460 | test_atom refs/tags/subject-body body 'first body line | |
461 | second body line | |
462 | ' | |
463 | test_atom refs/tags/subject-body contents 'the subject line | |
464 | ||
465 | first body line | |
466 | second body line | |
467 | ' | |
468 | ||
7f6e275b JK |
469 | test_expect_success 'create tag with multiline subject' ' |
470 | cat >msg <<-\EOF && | |
471 | first subject line | |
472 | second subject line | |
473 | ||
474 | first body line | |
475 | second body line | |
476 | EOF | |
477 | git tag -F msg multiline | |
478 | ' | |
479 | test_atom refs/tags/multiline subject 'first subject line second subject line' | |
e2b23972 | 480 | test_atom refs/tags/multiline contents:subject 'first subject line second subject line' |
7f6e275b JK |
481 | test_atom refs/tags/multiline body 'first body line |
482 | second body line | |
483 | ' | |
e2b23972 MG |
484 | test_atom refs/tags/multiline contents:body 'first body line |
485 | second body line | |
486 | ' | |
487 | test_atom refs/tags/multiline contents:signature '' | |
7f6e275b JK |
488 | test_atom refs/tags/multiline contents 'first subject line |
489 | second subject line | |
490 | ||
491 | first body line | |
492 | second body line | |
493 | ' | |
494 | ||
e2b23972 MG |
495 | test_expect_success GPG 'create signed tags' ' |
496 | git tag -s -m "" signed-empty && | |
497 | git tag -s -m "subject line" signed-short && | |
498 | cat >msg <<-\EOF && | |
499 | subject line | |
500 | ||
501 | body contents | |
502 | EOF | |
503 | git tag -s -F msg signed-long | |
504 | ' | |
505 | ||
506 | sig='-----BEGIN PGP SIGNATURE----- | |
507 | -----END PGP SIGNATURE----- | |
508 | ' | |
509 | ||
510 | PREREQ=GPG | |
511 | test_atom refs/tags/signed-empty subject '' | |
512 | test_atom refs/tags/signed-empty contents:subject '' | |
513 | test_atom refs/tags/signed-empty body "$sig" | |
514 | test_atom refs/tags/signed-empty contents:body '' | |
515 | test_atom refs/tags/signed-empty contents:signature "$sig" | |
516 | test_atom refs/tags/signed-empty contents "$sig" | |
517 | ||
518 | test_atom refs/tags/signed-short subject 'subject line' | |
519 | test_atom refs/tags/signed-short contents:subject 'subject line' | |
520 | test_atom refs/tags/signed-short body "$sig" | |
521 | test_atom refs/tags/signed-short contents:body '' | |
522 | test_atom refs/tags/signed-short contents:signature "$sig" | |
523 | test_atom refs/tags/signed-short contents "subject line | |
524 | $sig" | |
525 | ||
526 | test_atom refs/tags/signed-long subject 'subject line' | |
527 | test_atom refs/tags/signed-long contents:subject 'subject line' | |
528 | test_atom refs/tags/signed-long body "body contents | |
529 | $sig" | |
530 | test_atom refs/tags/signed-long contents:body 'body contents | |
531 | ' | |
532 | test_atom refs/tags/signed-long contents:signature "$sig" | |
533 | test_atom refs/tags/signed-long contents "subject line | |
534 | ||
535 | body contents | |
536 | $sig" | |
537 | ||
189a5467 RR |
538 | cat >expected <<EOF |
539 | $(git rev-parse refs/tags/master) <committer@example.com> refs/tags/master | |
540 | $(git rev-parse refs/tags/bogo) <committer@example.com> refs/tags/bogo | |
912072d5 KK |
541 | EOF |
542 | ||
3b51222c | 543 | test_expect_success 'Verify sort with multiple keys' ' |
912072d5 KK |
544 | git for-each-ref --format="%(objectname) %(taggeremail) %(refname)" --sort=objectname --sort=taggeremail \ |
545 | refs/tags/bogo refs/tags/master > actual && | |
546 | test_cmp expected actual | |
547 | ' | |
96b2d4fa | 548 | test_done |