@@ -7,6 +7,7 @@ test_description='test for-each-refs usage of ref-filter APIs'
7
7
8
8
test_expect_success ' setup some history and refs' '
9
9
test_commit one &&
10
+ git branch -M main &&
10
11
test_commit two &&
11
12
test_commit three &&
12
13
git checkout -b side &&
@@ -26,17 +27,17 @@ test_expect_success 'setup some history and refs' '
26
27
git tag $sign -m "A signed tag" signed-tag &&
27
28
git tag $sign -m "Signed doubly" doubly-signed-tag signed-tag &&
28
29
29
- git checkout master &&
30
- git update-ref refs/odd/spot master
30
+ git checkout main &&
31
+ git update-ref refs/odd/spot main
31
32
'
32
33
33
34
test_expect_success ' filtering with --points-at' '
34
35
cat >expect <<-\EOF &&
35
- refs/heads/master
36
+ refs/heads/main
36
37
refs/odd/spot
37
38
refs/tags/three
38
39
EOF
39
- git for-each-ref --format="%(refname)" --points-at=master >actual &&
40
+ git for-each-ref --format="%(refname)" --points-at=main >actual &&
40
41
test_cmp expect actual
41
42
'
42
43
@@ -53,13 +54,13 @@ test_expect_success 'check signed tags with --points-at' '
53
54
54
55
test_expect_success ' filtering with --merged' '
55
56
cat >expect <<-\EOF &&
56
- refs/heads/master
57
+ refs/heads/main
57
58
refs/odd/spot
58
59
refs/tags/one
59
60
refs/tags/three
60
61
refs/tags/two
61
62
EOF
62
- git for-each-ref --format="%(refname)" --merged=master >actual &&
63
+ git for-each-ref --format="%(refname)" --merged=main >actual &&
63
64
test_cmp expect actual
64
65
'
65
66
@@ -72,13 +73,13 @@ test_expect_success 'filtering with --no-merged' '
72
73
refs/tags/four
73
74
refs/tags/signed-tag
74
75
EOF
75
- git for-each-ref --format="%(refname)" --no-merged=master >actual &&
76
+ git for-each-ref --format="%(refname)" --no-merged=main >actual &&
76
77
test_cmp expect actual
77
78
'
78
79
79
80
test_expect_success ' filtering with --contains' '
80
81
cat >expect <<-\EOF &&
81
- refs/heads/master
82
+ refs/heads/main
82
83
refs/heads/side
83
84
refs/odd/spot
84
85
refs/tags/annotated-tag
@@ -113,7 +114,7 @@ test_expect_success '%(color) must fail' '
113
114
test_must_fail git for-each-ref --format="%(color)%(refname)"
114
115
'
115
116
116
- test_expect_success PREPARE_FOR_MAIN_BRANCH ' left alignment is default' '
117
+ test_expect_success ' left alignment is default' '
117
118
cat >expect <<-\EOF &&
118
119
refname is refs/heads/main |refs/heads/main
119
120
refname is refs/heads/side |refs/heads/side
@@ -131,7 +132,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH 'left alignment is default' '
131
132
test_cmp expect actual
132
133
'
133
134
134
- test_expect_success PREPARE_FOR_MAIN_BRANCH ' middle alignment' '
135
+ test_expect_success ' middle alignment' '
135
136
cat >expect <<-\EOF &&
136
137
| refname is refs/heads/main |refs/heads/main
137
138
| refname is refs/heads/side |refs/heads/side
@@ -149,7 +150,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH 'middle alignment' '
149
150
test_cmp expect actual
150
151
'
151
152
152
- test_expect_success PREPARE_FOR_MAIN_BRANCH ' right alignment' '
153
+ test_expect_success ' right alignment' '
153
154
cat >expect <<-\EOF &&
154
155
| refname is refs/heads/main|refs/heads/main
155
156
| refname is refs/heads/side|refs/heads/side
184
185
test_align_permutations () {
185
186
while read -r option
186
187
do
187
- test_expect_success PREPARE_FOR_MAIN_BRANCH " align:$option " '
188
+ test_expect_success " align:$option " '
188
189
git for-each-ref --format="|%(align:$option)refname is %(refname)%(end)|%(refname)" >actual &&
189
190
test_cmp expect actual
190
191
'
213
214
214
215
# Individual atoms inside %(align:...) and %(end) must not be quoted.
215
216
216
- test_expect_success PREPARE_FOR_MAIN_BRANCH ' alignment with format quote' "
217
+ test_expect_success ' alignment with format quote' "
217
218
cat >expect <<-\EOF &&
218
219
|' '\''main| A U Thor'\'' '|
219
220
|' '\''side| A U Thor'\'' '|
@@ -231,7 +232,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH 'alignment with format quote' "
231
232
test_cmp expect actual
232
233
"
233
234
234
- test_expect_success PREPARE_FOR_MAIN_BRANCH ' nested alignment with quote formatting' "
235
+ test_expect_success ' nested alignment with quote formatting' "
235
236
cat >expect <<-\EOF &&
236
237
|' main '|
237
238
|' side '|
@@ -251,7 +252,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH 'nested alignment with quote formatt
251
252
252
253
test_expect_success ' check `%(contents:lines=1)`' '
253
254
cat >expect <<-\EOF &&
254
- master |three
255
+ main |three
255
256
side |four
256
257
odd/spot |three
257
258
annotated-tag |An annotated tag
@@ -269,7 +270,7 @@ test_expect_success 'check `%(contents:lines=1)`' '
269
270
270
271
test_expect_success ' check `%(contents:lines=0)`' '
271
272
cat >expect <<-\EOF &&
272
- master |
273
+ main |
273
274
side |
274
275
odd/spot |
275
276
annotated-tag |
@@ -287,7 +288,7 @@ test_expect_success 'check `%(contents:lines=0)`' '
287
288
288
289
test_expect_success ' check `%(contents:lines=99999)`' '
289
290
cat >expect <<-\EOF &&
290
- master |three
291
+ main |three
291
292
side |four
292
293
odd/spot |three
293
294
annotated-tag |An annotated tag
@@ -360,7 +361,7 @@ test_expect_success 'improper usage of %(if), %(then), %(else) and %(end) atoms'
360
361
test_expect_success ' check %(if)...%(then)...%(end) atoms' '
361
362
git for-each-ref --format="%(refname)%(if)%(authorname)%(then) Author: %(authorname)%(end)" >actual &&
362
363
cat >expect <<-\EOF &&
363
- refs/heads/master Author: A U Thor
364
+ refs/heads/main Author: A U Thor
364
365
refs/heads/side Author: A U Thor
365
366
refs/odd/spot Author: A U Thor
366
367
refs/tags/annotated-tag
@@ -381,7 +382,7 @@ test_expect_success 'check %(if)...%(then)...%(end) atoms' '
381
382
test_expect_success ' check %(if)...%(then)...%(else)...%(end) atoms' '
382
383
git for-each-ref --format="%(if)%(authorname)%(then)%(authorname)%(else)No author%(end): %(refname)" >actual &&
383
384
cat >expect <<-\EOF &&
384
- A U Thor: refs/heads/master
385
+ A U Thor: refs/heads/main
385
386
A U Thor: refs/heads/side
386
387
A U Thor: refs/odd/spot
387
388
No author: refs/tags/annotated-tag
@@ -401,7 +402,7 @@ test_expect_success 'check %(if)...%(then)...%(else)...%(end) atoms' '
401
402
test_expect_success ' ignore spaces in %(if) atom usage' '
402
403
git for-each-ref --format="%(refname:short): %(if)%(HEAD)%(then)Head ref%(else)Not Head ref%(end)" >actual &&
403
404
cat >expect <<-\EOF &&
404
- master : Head ref
405
+ main : Head ref
405
406
side: Not Head ref
406
407
odd/spot: Not Head ref
407
408
annotated-tag: Not Head ref
@@ -420,19 +421,19 @@ test_expect_success 'ignore spaces in %(if) atom usage' '
420
421
'
421
422
422
423
test_expect_success ' check %(if:equals=<string>)' '
423
- git for-each-ref --format="%(if:equals=master )%(refname:short)%(then)Found master %(else)Not master %(end)" refs/heads/ >actual &&
424
+ git for-each-ref --format="%(if:equals=main )%(refname:short)%(then)Found main %(else)Not main %(end)" refs/heads/ >actual &&
424
425
cat >expect <<-\EOF &&
425
- Found master
426
- Not master
426
+ Found main
427
+ Not main
427
428
EOF
428
429
test_cmp expect actual
429
430
'
430
431
431
432
test_expect_success ' check %(if:notequals=<string>)' '
432
- git for-each-ref --format="%(if:notequals=master )%(refname:short)%(then)Not master %(else)Found master %(end)" refs/heads/ >actual &&
433
+ git for-each-ref --format="%(if:notequals=main )%(refname:short)%(then)Not main %(else)Found main %(end)" refs/heads/ >actual &&
433
434
cat >expect <<-\EOF &&
434
- Found master
435
- Not master
435
+ Found main
436
+ Not main
436
437
EOF
437
438
test_cmp expect actual
438
439
'
@@ -443,11 +444,11 @@ test_expect_success '--merged is compatible with --no-merged' '
443
444
444
445
test_expect_success ' validate worktree atom' '
445
446
cat >expect <<-EOF &&
446
- master : $(pwd)
447
- master_worktree : $(pwd)/worktree_dir
447
+ main : $(pwd)
448
+ main_worktree : $(pwd)/worktree_dir
448
449
side: not checked out
449
450
EOF
450
- git worktree add -b master_worktree worktree_dir master &&
451
+ git worktree add -b main_worktree worktree_dir main &&
451
452
git for-each-ref --format="%(refname:short): %(if)%(worktreepath)%(then)%(worktreepath)%(else)not checked out%(end)" refs/heads/ >actual &&
452
453
rm -r worktree_dir &&
453
454
git worktree prune &&
0 commit comments