]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7400: test failure to add submodule in tracked path
authorAtharva Raykar <raykar.ath@gmail.com>
Tue, 6 Jul 2021 18:19:34 +0000 (23:49 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 Jul 2021 18:00:01 +0000 (11:00 -0700)
Add a test to ensure failure on adding a submodule to a directory with
tracked contents in the index.

As we are going to refactor and port to C some parts of `git submodule
add`, let's add a test to help ensure no regression is introduced.

Signed-off-by: Atharva Raykar <raykar.ath@gmail.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Based-on-patch-by: Shourya Shukla <periperidip@gmail.com>
Mentored-by: Shourya Shukla <periperidip@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7400-submodule-basic.sh

index a924fdb7a6c9aaf6c1b860dd4c783d87b803c36f..7aa7fefdfa9a62f38ca5d226fd503a071d4c4e30 100755 (executable)
@@ -196,6 +196,17 @@ test_expect_success 'submodule add to .gitignored path with --force' '
        )
 '
 
+test_expect_success 'submodule add to path with tracked content fails' '
+       (
+               cd addtest &&
+               echo "'\''dir-tracked'\'' already exists in the index" >expect &&
+               mkdir dir-tracked &&
+               test_commit foo dir-tracked/bar &&
+               test_must_fail git submodule add "$submodurl" dir-tracked >actual 2>&1 &&
+               test_cmp expect actual
+       )
+'
+
 test_expect_success 'submodule add to reconfigure existing submodule with --force' '
        (
                cd addtest-ignore &&