Skip to content

Commit 596ad33

Browse files
committed
Merge branch 'js/default-branch-name-part-4-minus-1'
Adjust tests so that they won't scream when the default initial branch name is changed to 'main'. * js/default-branch-name-part-4-minus-1: t1400: prepare for `main` being default branch name tests: prepare aligned mentions of the default branch name t9902: prepare a test for the upcoming default branch name t3200: prepare for `main` being shorter than `master` t5703: adjust a test case for the upcoming default branch name t6200: adjust suppression pattern to also match "main" tests: start moving to a different default main branch name t9801: use `--` in preparation for default branch rename fmt-merge-msg: also suppress "into main" by default
2 parents 292e53f + 3224b0f commit 596ad33

19 files changed

+130
-108
lines changed

fmt-merge-msg.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,10 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
626626
void *current_branch_to_free;
627627
struct merge_parents merge_parents;
628628

629-
if (!suppress_dest_pattern_seen)
629+
if (!suppress_dest_pattern_seen) {
630+
string_list_append(&suppress_dest_patterns, "main");
630631
string_list_append(&suppress_dest_patterns, "master");
632+
}
631633

632634
memset(&merge_parents, 0, sizeof(merge_parents));
633635

refs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,11 @@ char *repo_default_branch_name(struct repository *r)
567567
const char *config_key = "init.defaultbranch";
568568
const char *config_display_key = "init.defaultBranch";
569569
char *ret = NULL, *full_ref;
570+
const char *env = getenv("GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME");
570571

571-
if (repo_config_get_string(r, config_key, &ret) < 0)
572+
if (env && *env)
573+
ret = xstrdup(env);
574+
else if (repo_config_get_string(r, config_key, &ret) < 0)
572575
die(_("could not retrieve `%s`"), config_display_key);
573576

574577
if (!ret)

t/lib-submodule-update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ create_lib_submodule_repo () {
144144
git checkout -b valid_sub1 &&
145145
git revert HEAD &&
146146

147-
git checkout master
147+
git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}"
148148
)
149149
}
150150

t/t0001-init.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,21 @@ test_expect_success '--initial-branch' '
553553

554554
test_expect_success 'overridden default initial branch name (config)' '
555555
test_config_global init.defaultBranch nmb &&
556-
git init initial-branch-config &&
556+
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= git init initial-branch-config &&
557557
git -C initial-branch-config symbolic-ref HEAD >actual &&
558558
grep nmb actual
559559
'
560560

561+
test_expect_success 'overridden default main branch name (env)' '
562+
test_config_global init.defaultBranch nmb &&
563+
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=env git init main-branch-env &&
564+
git -C main-branch-env symbolic-ref HEAD >actual &&
565+
grep env actual
566+
'
567+
561568
test_expect_success 'invalid default branch name' '
562-
test_config_global init.defaultBranch "with space" &&
563-
test_must_fail git init initial-branch-invalid 2>err &&
569+
test_must_fail env GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME="with space" \
570+
git init initial-branch-invalid 2>err &&
564571
test_i18ngrep "invalid branch name" err
565572
'
566573

t/t1400-update-ref.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,10 @@ test_expect_success 'stdin fails on unbalanced quotes' '
585585
grep "fatal: badly quoted argument: \\\"master" err
586586
'
587587

588-
test_expect_success 'stdin fails on invalid escape' '
589-
echo "create $a \"ma\zter\"" >stdin &&
588+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin fails on invalid escape' '
589+
echo "create $a \"ma\zn\"" >stdin &&
590590
test_must_fail git update-ref --stdin <stdin 2>err &&
591-
grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err
591+
grep "fatal: badly quoted argument: \\\"ma\\\\zn\\\"" err
592592
'
593593

594594
test_expect_success 'stdin fails on junk after quoted argument' '
@@ -704,9 +704,9 @@ test_expect_success 'stdin succeeds with quoted argument' '
704704
test_cmp expect actual
705705
'
706706

707-
test_expect_success 'stdin succeeds with escaped character' '
707+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin succeeds with escaped character' '
708708
git update-ref -d $a &&
709-
echo "create $a \"ma\\163ter\"" >stdin &&
709+
echo "create $a \"ma\\151n\"" >stdin &&
710710
git update-ref --stdin <stdin &&
711711
git rev-parse $m >expect &&
712712
git rev-parse $a >actual &&

t/t3200-branch.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ test_expect_success 'git branch --list -v with --abbrev' '
321321
322322
'
323323

324-
test_expect_success 'git branch --column' '
324+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch --column' '
325325
COLUMNS=81 git branch --column=column >actual &&
326326
cat >expect <<\EOF &&
327-
a/b/c bam foo l * master n o/p r
328-
abc bar j/k m/m mb o/o q topic
327+
a/b/c bam foo l * main n o/p r
328+
abc bar j/k m/m mb o/o q topic
329329
EOF
330330
test_cmp expect actual
331331
'
@@ -358,15 +358,15 @@ EOF
358358
test_cmp expect actual
359359
'
360360

361-
test_expect_success 'git branch with column.*' '
361+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch with column.*' '
362362
git config column.ui column &&
363363
git config column.branch "dense" &&
364364
COLUMNS=80 git branch >actual &&
365365
git config --unset column.branch &&
366366
git config --unset column.ui &&
367367
cat >expect <<\EOF &&
368-
a/b/c bam foo l * master n o/p r
369-
abc bar j/k m/m mb o/o q topic
368+
a/b/c bam foo l * main n o/p r
369+
abc bar j/k m/m mb o/o q topic
370370
EOF
371371
test_cmp expect actual
372372
'
@@ -375,9 +375,9 @@ test_expect_success 'git branch --column -v should fail' '
375375
test_must_fail git branch --column -v
376376
'
377377

378-
test_expect_success 'git branch -v with column.ui ignored' '
378+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch -v with column.ui ignored' '
379379
git config column.ui column &&
380-
COLUMNS=80 git branch -v | cut -c -9 | sed "s/ *$//" >actual &&
380+
COLUMNS=80 git branch -v | cut -c -8 | sed "s/ *$//" >actual &&
381381
git config --unset column.ui &&
382382
cat >expect <<\EOF &&
383383
a/b/c

t/t3201-branch-contains.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ test_expect_success 'branch --merged combined with --no-merged' '
242242
# Here "topic" tracks "master" with one extra commit, and "zzz" points to the
243243
# same tip as master The name "zzz" must come alphabetically after "topic"
244244
# as we process them in that order.
245-
test_expect_success 'branch --merged with --verbose' '
245+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'branch --merged with --verbose' '
246246
git branch --track topic master &&
247247
git branch zzz topic &&
248248
git checkout topic &&
@@ -256,9 +256,9 @@ test_expect_success 'branch --merged with --verbose' '
256256
test_cmp expect actual &&
257257
git branch --verbose --merged topic >actual &&
258258
cat >expect <<-EOF &&
259-
master $(git rev-parse --short master) second on master
260-
* topic $(git rev-parse --short topic ) [ahead 1] foo
261-
zzz $(git rev-parse --short zzz ) second on master
259+
main $(git rev-parse --short main) second on main
260+
* topic $(git rev-parse --short topic ) [ahead 1] foo
261+
zzz $(git rev-parse --short zzz ) second on main
262262
EOF
263263
test_i18ncmp expect actual
264264
'

t/t3203-branch-output.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,15 @@ test_expect_success '--color overrides auto-color' '
329329
test_cmp expect.color actual
330330
'
331331

332-
test_expect_success 'verbose output lists worktree path' '
332+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'verbose output lists worktree path' '
333333
one=$(git rev-parse --short HEAD) &&
334334
two=$(git rev-parse --short master) &&
335335
cat >expect <<-EOF &&
336336
* (HEAD detached from fromtag) $one one
337337
ambiguous $one one
338338
branch-one $two two
339339
+ branch-two $one ($(pwd)/worktree_dir) one
340-
master $two two
340+
main $two two
341341
ref-to-branch $two two
342342
ref-to-remote $two two
343343
EOF

t/t3205-branch-color.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ test_expect_success 'regular output shows colors' '
2828
test_cmp expect actual
2929
'
3030

31-
test_expect_success 'verbose output shows colors' '
31+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'verbose output shows colors' '
3232
oid=$(git rev-parse --short HEAD) &&
3333
cat >expect <<-EOF &&
34-
* <CYAN>master <RESET> $oid foo
35-
<BLUE>other <RESET> $oid foo
36-
<YELLOW>remotes/origin/master<RESET> $oid foo
34+
* <CYAN>main <RESET> $oid foo
35+
<BLUE>other <RESET> $oid foo
36+
<YELLOW>remotes/origin/main<RESET> $oid foo
3737
EOF
3838
git branch --color -v -a >actual.raw &&
3939
test_decode_color <actual.raw >actual &&

t/t5505-remote.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -213,28 +213,28 @@ cat >test/expect <<EOF
213213
Push URL: $(pwd)/one
214214
HEAD branch: master
215215
Remote branches:
216-
master new (next fetch will store in remotes/origin)
217-
side tracked
216+
main new (next fetch will store in remotes/origin)
217+
side tracked
218218
Local branches configured for 'git pull':
219-
ahead merges with remote master
220-
master merges with remote master
219+
ahead merges with remote main
220+
main merges with remote main
221221
octopus merges with remote topic-a
222222
and with remote topic-b
223223
and with remote topic-c
224224
rebase rebases onto remote master
225225
Local refs configured for 'git push':
226-
master pushes to master (local out of date)
227-
master pushes to upstream (create)
226+
main pushes to main (local out of date)
227+
main pushes to upstream (create)
228228
* remote two
229229
Fetch URL: ../two
230230
Push URL: ../three
231231
HEAD branch: master
232232
Local refs configured for 'git push':
233-
ahead forces to master (fast-forwardable)
234-
master pushes to another (up to date)
233+
ahead forces to main (fast-forwardable)
234+
main pushes to another (up to date)
235235
EOF
236236

237-
test_expect_success 'show' '
237+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'show' '
238238
(
239239
cd test &&
240240
git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
@@ -277,15 +277,15 @@ cat >test/expect <<EOF
277277
master
278278
side
279279
Local branches configured for 'git pull':
280-
ahead merges with remote master
281-
master merges with remote master
280+
ahead merges with remote main
281+
main merges with remote main
282282
Local refs configured for 'git push' (status not queried):
283283
(matching) pushes to (matching)
284-
refs/heads/master pushes to refs/heads/upstream
284+
refs/heads/main pushes to refs/heads/upstream
285285
refs/tags/lastbackup forces to refs/tags/lastbackup
286286
EOF
287287

288-
test_expect_success 'show -n' '
288+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'show -n' '
289289
mv one one.unreachable &&
290290
(
291291
cd test &&
@@ -328,7 +328,7 @@ test_expect_success 'set-head --auto' '
328328
)
329329
'
330330

331-
test_expect_success 'set-head --auto has no problem w/multiple HEADs' '
331+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'set-head --auto has no problem w/multiple HEADs' '
332332
(
333333
cd test &&
334334
git fetch two "refs/heads/*:refs/remotes/two/*" &&
@@ -1348,7 +1348,7 @@ test_expect_success 'unqualified <dst> refspec DWIM and advice' '
13481348
)
13491349
'
13501350

1351-
test_expect_success 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' '
1351+
test_expect_success PREPARE_FOR_MAIN_BRANCH 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' '
13521352
(
13531353
cd two &&
13541354
git tag -a -m "Some tag" my-tag master &&

0 commit comments

Comments
 (0)