Skip to content

Commit 8d48dd1

Browse files
phil-blaingitster
authored andcommitted
t/lib-submodule-update: move a test to the right section
The test "$command: submodule branch is not changed, detach HEAD instead" is in the "Appearing submodule" section of test_submodule_recursing_with_args_common(), but this test updates a submodule; it does not test a transition from a state with no submodule to a state with a submodule. As such, for consistency, move it to the "Modified submodule" section of the same function. While at it, add a comment describing the test. Signed-off-by: Philippe Blain <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d5779b6 commit 8d48dd1

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

t/lib-submodule-update.sh

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -658,22 +658,6 @@ test_submodule_recursing_with_args_common() {
658658
test_submodule_content sub1 origin/add_sub1
659659
)
660660
'
661-
test_expect_success "$command: submodule branch is not changed, detach HEAD instead" '
662-
prolog &&
663-
reset_work_tree_to_interested add_sub1 &&
664-
(
665-
cd submodule_update &&
666-
git -C sub1 checkout -b keep_branch &&
667-
git -C sub1 rev-parse HEAD >expect &&
668-
git branch -t modify_sub1 origin/modify_sub1 &&
669-
$command modify_sub1 &&
670-
test_superproject_content origin/modify_sub1 &&
671-
test_submodule_content sub1 origin/modify_sub1 &&
672-
git -C sub1 rev-parse keep_branch >actual &&
673-
test_cmp expect actual &&
674-
test_must_fail git -C sub1 symbolic-ref HEAD
675-
)
676-
'
677661

678662
# Replacing a tracked file with a submodule produces a checked out submodule
679663
test_expect_success "$command: replace tracked file with submodule checks out submodule" '
@@ -789,6 +773,23 @@ test_submodule_recursing_with_args_common() {
789773
test_submodule_content sub1 origin/add_sub1
790774
)
791775
'
776+
# Updating a submodule does not touch the currently checked out branch in the submodule
777+
test_expect_success "$command: submodule branch is not changed, detach HEAD instead" '
778+
prolog &&
779+
reset_work_tree_to_interested add_sub1 &&
780+
(
781+
cd submodule_update &&
782+
git -C sub1 checkout -b keep_branch &&
783+
git -C sub1 rev-parse HEAD >expect &&
784+
git branch -t modify_sub1 origin/modify_sub1 &&
785+
$command modify_sub1 &&
786+
test_superproject_content origin/modify_sub1 &&
787+
test_submodule_content sub1 origin/modify_sub1 &&
788+
git -C sub1 rev-parse keep_branch >actual &&
789+
test_cmp expect actual &&
790+
test_must_fail git -C sub1 symbolic-ref HEAD
791+
)
792+
'
792793
}
793794

794795
# Declares and invokes several tests that, in various situations, checks that

0 commit comments

Comments
 (0)