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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Dec 4, 2020 at 14:34 UTC
b618a2d9dfdbcd333e4a1ef2b1d4894109c985b0
1 file changed
+22
-19
t/t5526-fetch-submodules.sh
+22
-19
@@ -18,7 +18,7 @@ add_upstream_commit() {
18
head2=$(git rev-parse --short HEAD) &&
19
echo "Fetching submodule submodule" > ../expect.err &&
20
echo "From $pwd/submodule" >> ../expect.err &&
21
- echo " $head1..$head2 main -> origin/main" >> ../expect.err
21
+ echo " $head1..$head2 sub -> origin/sub" >> ../expect.err
22
) &&
23
(
24
cd deepsubmodule &&
@@ -30,7 +30,7 @@ add_upstream_commit() {
30
head2=$(git rev-parse --short HEAD) &&
31
echo "Fetching submodule submodule/subdir/deepsubmodule" >> ../expect.err
32
echo "From $pwd/deepsubmodule" >> ../expect.err &&
33
- echo " $head1..$head2 main -> origin/main" >> ../expect.err
33
+ echo " $head1..$head2 deep -> origin/deep" >> ../expect.err
34
)
35
}
36
@@ -41,7 +41,8 @@ test_expect_success setup '
41
git init &&
42
echo deepsubcontent > deepsubfile &&
43
git add deepsubfile &&
44
- git commit -m new deepsubfile
44
+ git commit -m new deepsubfile &&
45
+ git branch -M deep
46
) &&
47
mkdir submodule &&
48
(
@@ -50,10 +51,12 @@ test_expect_success setup '
51
echo subcontent > subfile &&
52
git add subfile &&
53
git submodule add "$pwd/deepsubmodule" subdir/deepsubmodule &&
53
- git commit -a -m new
54
+ git commit -a -m new &&
55
+ git branch -M sub
56
) &&
57
git submodule add "$pwd/submodule" submodule &&
58
git commit -am initial &&
59
+ git branch -M super &&
60
git clone . downstream &&
61
(
62
cd downstream &&
@@ -245,7 +248,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion stops when no new submodu
248
git commit -m "new submodule" &&
249
head2=$(git rev-parse --short HEAD) &&
250
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 &&
252
head -3 expect.err >> expect.err.sub &&
253
(
254
cd downstream &&
@@ -263,7 +266,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion doesn't happen when new s
266
git commit -m "new file" &&
267
head2=$(git rev-parse --short HEAD) &&
268
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 &&
270
(
271
cd downstream &&
272
git fetch >../actual.out 2>../actual.err
@@ -287,7 +290,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion picks up config in submod
290
git commit -m "new submodule" &&
291
head2=$(git rev-parse --short HEAD) &&
292
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 &&
294
cat expect.err >> expect.err.sub &&
295
(
296
cd downstream &&
@@ -316,14 +319,14 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion picks up all submodules w
319
head2=$(git rev-parse --short HEAD) &&
320
echo "Fetching submodule submodule" > ../expect.err.sub &&
321
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
323
) &&
324
head1=$(git rev-parse --short HEAD) &&
325
git add submodule &&
326
git commit -m "new submodule" &&
327
head2=$(git rev-parse --short HEAD) &&
328
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 &&
330
cat expect.err.sub >> expect.err.2 &&
331
tail -3 expect.err >> expect.err.2 &&
332
(
@@ -349,7 +352,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' do
352
head2=$(git rev-parse --short HEAD) &&
353
echo Fetching submodule submodule > ../expect.err.sub &&
354
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
356
) &&
357
(
358
cd downstream &&
@@ -368,7 +371,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' re
371
head2=$(git rev-parse --short HEAD) &&
372
tail -3 expect.err > expect.err.deepsub &&
373
echo "From $pwd/." > expect.err &&
371
- echo " $head1..$head2 main -> origin/main" >>expect.err &&
374
+ echo " $head1..$head2 super -> origin/super" >>expect.err &&
375
cat expect.err.sub >> expect.err &&
376
cat expect.err.deepsub >> expect.err &&
377
(
@@ -397,7 +400,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' st
400
git commit -m "new file" &&
401
head2=$(git rev-parse --short HEAD) &&
402
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 &&
404
(
405
cd downstream &&
406
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'
421
git commit -m "new submodule" &&
422
head2=$(git rev-parse --short HEAD) &&
423
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 &&
425
head -3 expect.err >> expect.err.2 &&
426
(
427
cd downstream &&
@@ -446,7 +449,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'submodule.<sub>.fetchRecurseSubmod
449
git commit -m "new submodule" &&
450
head2=$(git rev-parse --short HEAD) &&
451
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 &&
453
head -3 expect.err >> expect.err.2 &&
454
(
455
cd downstream &&
@@ -472,7 +475,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "don't fetch submodule when newly re
475
git commit -m "submodule rewound" &&
476
head2=$(git rev-parse --short HEAD) &&
477
echo "From $pwd/." > expect.err &&
475
- echo " $head1..$head2 main -> origin/main" >> expect.err &&
478
+ echo " $head1..$head2 super -> origin/super" >> expect.err &&
479
(
480
cd downstream &&
481
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
484
test_i18ncmp expect.err actual.err &&
485
(
486
cd submodule &&
484
- git checkout -q master
487
+ git checkout -q sub
488
)
489
'
490
@@ -497,7 +500,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH "'fetch.recurseSubmodules=on-demand'
500
git commit -m "new submodule without .gitmodules" &&
501
head2=$(git rev-parse --short HEAD) &&
502
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 &&
504
head -3 expect.err >>expect.err.2 &&
505
(
506
cd downstream &&
@@ -663,9 +666,9 @@ test_expect_success 'fetch new submodule commits on-demand without .gitmodules e
666
git config -f .gitmodules --remove-section submodule.sub1 &&
667
git add .gitmodules &&
668
git commit -m "delete gitmodules file" &&
666
- git checkout -B master &&
669
+ git checkout -B super &&
670
git -C downstream fetch &&
668
- git -C downstream checkout origin/master &&
671
+ git -C downstream checkout origin/super &&
672
673
C=$(git -C submodule commit-tree -m "yet another change outside refs/heads" HEAD^{tree}) &&
674
git -C submodule update-ref refs/changes/7 $C &&