Skip to content

Commit b027fb0

Browse files
heftiggitster
authored andcommitted
t7419: actually test the branch switching
The submodule repo the test set up had the 'topic' branch checked out, meaning the repo's default branch (HEAD) is the 'topic' branch. The following tests then pretended to switch between the default branch and the 'topic' branch. This was papered over by continually adding commits to the 'topic' branch and checking if the submodule gets updated to this new commit. Return the submodule repo to the 'main' branch after setup so we can actually test the switching behavior. Signed-off-by: Jan Alexander Steffens (heftig) <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 387c122 commit b027fb0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

t/t7419-submodule-set-branch.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ as expected.
1111

1212
TEST_PASSES_SANITIZE_LEAK=true
1313
TEST_NO_CREATE_REPO=1
14+
15+
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
16+
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
17+
1418
. ./test-lib.sh
1519

1620
test_expect_success 'setup' '
@@ -27,7 +31,8 @@ test_expect_success 'submodule config cache setup' '
2731
git checkout -b topic &&
2832
echo b >a &&
2933
git add . &&
30-
git commit -mb
34+
git commit -mb &&
35+
git checkout main
3136
) &&
3237
mkdir super &&
3338
(cd super &&
@@ -57,21 +62,19 @@ test_expect_success 'test submodule set-branch --branch' '
5762
'
5863

5964
test_expect_success 'test submodule set-branch --default' '
60-
test_commit -C submodule c &&
6165
(cd super &&
6266
git submodule set-branch --default submodule &&
6367
! grep branch .gitmodules &&
6468
git submodule update --remote &&
6569
cat <<-\EOF >expect &&
66-
c
70+
a
6771
EOF
6872
git -C submodule show -s --pretty=%s >actual &&
6973
test_cmp expect actual
7074
)
7175
'
7276

7377
test_expect_success 'test submodule set-branch -b' '
74-
test_commit -C submodule b &&
7578
(cd super &&
7679
git submodule set-branch -b topic submodule &&
7780
grep "branch = topic" .gitmodules &&
@@ -85,13 +88,12 @@ test_expect_success 'test submodule set-branch -b' '
8588
'
8689

8790
test_expect_success 'test submodule set-branch -d' '
88-
test_commit -C submodule d &&
8991
(cd super &&
9092
git submodule set-branch -d submodule &&
9193
! grep branch .gitmodules &&
9294
git submodule update --remote &&
9395
cat <<-\EOF >expect &&
94-
d
96+
a
9597
EOF
9698
git -C submodule show -s --pretty=%s >actual &&
9799
test_cmp expect actual

0 commit comments

Comments
 (0)