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 <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Philippe Blain committed
Feb 17, 2020 at 04:53 UTC
8d48dd1988e90c7bfa966eb324ed98849528502a
1 file changed
+17
-16
t/lib-submodule-update.sh
+17
-16
@@ -658,22 +658,6 @@ test_submodule_recursing_with_args_common() {
658
test_submodule_content sub1 origin/add_sub1
659
)
660
'
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
- '
661
662
# Replacing a tracked file with a submodule produces a checked out submodule
663
test_expect_success "$command: replace tracked file with submodule checks out submodule" '
@@ -789,6 +773,23 @@ test_submodule_recursing_with_args_common() {
773
test_submodule_content sub1 origin/add_sub1
774
)
775
'
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
+ '
793
}
794
795
# Declares and invokes several tests that, in various situations, checks that