Skip to content

Commit b618a2d

Browse files
dschogitster
authored andcommitted
t5526: avoid depending on a specific default branch name
While at it, use different default branch names for the three different repositories involved in the test script: this makes it easier to debug failures, too (otherwise you have to wonder which `master` branch was meant: the super project's? The submodule's? The nested submodule's?). Note: this touches code that was originally modified to prepare for renaming the default branch name to `main`. This patch side-steps that effort completely by overriding the initial branch name explicitly. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3a0b884 commit b618a2d

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

t/t5526-fetch-submodules.sh

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ add_upstream_commit() {
1818
head2=$(git rev-parse --short HEAD) &&
1919
echo "Fetching submodule submodule" > ../expect.err &&
2020
echo "From $pwd/submodule" >> ../expect.err &&
21-
echo " $head1..$head2 main -> origin/main" >> ../expect.err
21+
echo " $head1..$head2 sub -> origin/sub" >> ../expect.err
2222
) &&
2323
(
2424
cd deepsubmodule &&
@@ -30,7 +30,7 @@ add_upstream_commit() {
3030
head2=$(git rev-parse --short HEAD) &&
3131
echo "Fetching submodule submodule/subdir/deepsubmodule" >> ../expect.err
3232
echo "From $pwd/deepsubmodule" >> ../expect.err &&
33-
echo " $head1..$head2 main -> origin/main" >> ../expect.err
33+
echo " $head1..$head2 deep -> origin/deep" >> ../expect.err
3434
)
3535
}
3636

@@ -41,7 +41,8 @@ test_expect_success setup '
4141
git init &&
4242
echo deepsubcontent > deepsubfile &&
4343
git add deepsubfile &&
44-
git commit -m new deepsubfile
44+
git commit -m new deepsubfile &&
45+
git branch -M deep
4546
) &&
4647
mkdir submodule &&
4748
(
@@ -50,10 +51,12 @@ test_expect_success setup '
5051
echo subcontent > subfile &&
5152
git add subfile &&
5253
git submodule add "$pwd/deepsubmodule" subdir/deepsubmodule &&
53-
git commit -a -m new
54+
git commit -a -m new &&
55+
git branch -M sub
5456
) &&
5557
git submodule add "$pwd/submodule" submodule &&
5658
git commit -am initial &&
59+
git branch -M super &&
5760
git clone . downstream &&
5861
(
5962
cd downstream &&
@@ -245,7 +248,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion stops when no new submodu
245248
git commit -m "new submodule" &&
246249
head2=$(git rev-parse --short HEAD) &&
247250
echo "From $pwd/." > expect.err.sub &&
248-
echo " $head1..$head2 main -> origin/main" >>expect.err.sub &&
251+
echo " $head1..$head2 super -> origin/super" >>expect.err.sub &&
249252
head -3 expect.err >> expect.err.sub &&
250253
(
251254
cd downstream &&
@@ -263,7 +266,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion doesn't happen when new s
263266
git commit -m "new file" &&
264267
head2=$(git rev-parse --short HEAD) &&
265268
echo "From $pwd/." > expect.err.file &&
266-
echo " $head1..$head2 main -> origin/main" >> expect.err.file &&
269+
echo " $head1..$head2 super -> origin/super" >> expect.err.file &&
267270
(
268271
cd downstream &&
269272
git fetch >../actual.out 2>../actual.err
@@ -287,7 +290,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion picks up config in submod
287290
git commit -m "new submodule" &&
288291
head2=$(git rev-parse --short HEAD) &&
289292
echo "From $pwd/." > expect.err.sub &&
290-
echo " $head1..$head2 main -> origin/main" >> expect.err.sub &&
293+
echo " $head1..$head2 super -> origin/super" >> expect.err.sub &&
291294
cat expect.err >> expect.err.sub &&
292295
(
293296
cd downstream &&
@@ -316,14 +319,14 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion picks up all submodules w
316319
head2=$(git rev-parse --short HEAD) &&
317320
echo "Fetching submodule submodule" > ../expect.err.sub &&
318321
echo "From $pwd/submodule" >> ../expect.err.sub &&
319-
echo " $head1..$head2 main -> origin/main" >> ../expect.err.sub
322+
echo " $head1..$head2 sub -> origin/sub" >> ../expect.err.sub
320323
) &&
321324
head1=$(git rev-parse --short HEAD) &&
322325
git add submodule &&
323326
git commit -m "new submodule" &&
324327
head2=$(git rev-parse --short HEAD) &&
325328
echo "From $pwd/." > expect.err.2 &&
326-
echo " $head1..$head2 main -> origin/main" >> expect.err.2 &&
329+
echo " $head1..$head2 super -> origin/super" >> expect.err.2 &&
327330
cat expect.err.sub >> expect.err.2 &&
328331
tail -3 expect.err >> expect.err.2 &&
329332
(
@@ -349,7 +352,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' do
349352
head2=$(git rev-parse --short HEAD) &&
350353
echo Fetching submodule submodule > ../expect.err.sub &&
351354
echo "From $pwd/submodule" >> ../expect.err.sub &&
352-
echo " $head1..$head2 main -> origin/main" >> ../expect.err.sub
355+
echo " $head1..$head2 sub -> origin/sub" >> ../expect.err.sub
353356
) &&
354357
(
355358
cd downstream &&
@@ -368,7 +371,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' re
368371
head2=$(git rev-parse --short HEAD) &&
369372
tail -3 expect.err > expect.err.deepsub &&
370373
echo "From $pwd/." > expect.err &&
371-
echo " $head1..$head2 main -> origin/main" >>expect.err &&
374+
echo " $head1..$head2 super -> origin/super" >>expect.err &&
372375
cat expect.err.sub >> expect.err &&
373376
cat expect.err.deepsub >> expect.err &&
374377
(
@@ -397,7 +400,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' st
397400
git commit -m "new file" &&
398401
head2=$(git rev-parse --short HEAD) &&
399402
echo "From $pwd/." > expect.err.file &&
400-
echo " $head1..$head2 main -> origin/main" >> expect.err.file &&
403+
echo " $head1..$head2 super -> origin/super" >> expect.err.file &&
401404
(
402405
cd downstream &&
403406
git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err
@@ -418,7 +421,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'fetch.recurseSubmodules=on-demand'
418421
git commit -m "new submodule" &&
419422
head2=$(git rev-parse --short HEAD) &&
420423
echo "From $pwd/." > expect.err.2 &&
421-
echo " $head1..$head2 main -> origin/main" >>expect.err.2 &&
424+
echo " $head1..$head2 super -> origin/super" >>expect.err.2 &&
422425
head -3 expect.err >> expect.err.2 &&
423426
(
424427
cd downstream &&
@@ -446,7 +449,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'submodule.<sub>.fetchRecurseSubmod
446449
git commit -m "new submodule" &&
447450
head2=$(git rev-parse --short HEAD) &&
448451
echo "From $pwd/." > expect.err.2 &&
449-
echo " $head1..$head2 main -> origin/main" >>expect.err.2 &&
452+
echo " $head1..$head2 super -> origin/super" >>expect.err.2 &&
450453
head -3 expect.err >> expect.err.2 &&
451454
(
452455
cd downstream &&
@@ -472,7 +475,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "don't fetch submodule when newly re
472475
git commit -m "submodule rewound" &&
473476
head2=$(git rev-parse --short HEAD) &&
474477
echo "From $pwd/." > expect.err &&
475-
echo " $head1..$head2 main -> origin/main" >> expect.err &&
478+
echo " $head1..$head2 super -> origin/super" >> expect.err &&
476479
(
477480
cd downstream &&
478481
git fetch >../actual.out 2>../actual.err
@@ -481,7 +484,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "don't fetch submodule when newly re
481484
test_i18ncmp expect.err actual.err &&
482485
(
483486
cd submodule &&
484-
git checkout -q master
487+
git checkout -q sub
485488
)
486489
'
487490

@@ -497,7 +500,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'fetch.recurseSubmodules=on-demand'
497500
git commit -m "new submodule without .gitmodules" &&
498501
head2=$(git rev-parse --short HEAD) &&
499502
echo "From $pwd/." >expect.err.2 &&
500-
echo " $head1..$head2 main -> origin/main" >>expect.err.2 &&
503+
echo " $head1..$head2 super -> origin/super" >>expect.err.2 &&
501504
head -3 expect.err >>expect.err.2 &&
502505
(
503506
cd downstream &&
@@ -663,9 +666,9 @@ test_expect_success 'fetch new submodule commits on-demand without .gitmodules e
663666
git config -f .gitmodules --remove-section submodule.sub1 &&
664667
git add .gitmodules &&
665668
git commit -m "delete gitmodules file" &&
666-
git checkout -B master &&
669+
git checkout -B super &&
667670
git -C downstream fetch &&
668-
git -C downstream checkout origin/master &&
671+
git -C downstream checkout origin/super &&
669672
670673
C=$(git -C submodule commit-tree -m "yet another change outside refs/heads" HEAD^{tree}) &&
671674
git -C submodule update-ref refs/changes/7 $C &&

0 commit comments

Comments
 (0)