3 test_description
='check that submodule operations do not follow symlinks'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'prepare' '
9 git config --global protocol.file.allow always &&
10 test_commit initial &&
12 test_commit -C upstream upstream submodule_file &&
13 git submodule add ./upstream a/sm &&
15 git commit -m submodule
18 test_expect_success SYMLINKS
'git submodule update must not create submodule behind symlink' '
22 test_path_is_missing b/sm &&
23 test_must_fail git submodule update &&
24 test_path_is_missing b/sm
27 test_expect_success SYMLINKS
,CASE_INSENSITIVE_FS
'git submodule update must not create submodule behind symlink on case insensitive fs' '
31 test_must_fail git submodule update &&
32 test_path_is_missing b/sm
35 prepare_symlink_to_repo
() {
39 git
-C a
/target fetch ..
/..
/upstream
&&
43 test_expect_success SYMLINKS
'git restore --recurse-submodules must not be confused by a symlink' '
44 prepare_symlink_to_repo &&
45 test_must_fail git restore --recurse-submodules a/sm &&
46 test_path_is_missing a/sm/submodule_file &&
47 test_path_is_dir a/target/.git &&
48 test_path_is_missing a/target/submodule_file
51 test_expect_success SYMLINKS
'git restore --recurse-submodules must not migrate git dir of symlinked repo' '
52 prepare_symlink_to_repo &&
53 rm -rf .git/modules &&
54 test_must_fail git restore --recurse-submodules a/sm &&
55 test_path_is_dir a/target/.git &&
56 test_path_is_missing .git/modules/a/sm &&
57 test_path_is_missing a/target/submodule_file
60 test_expect_success SYMLINKS
'git checkout -f --recurse-submodules must not migrate git dir of symlinked repo when removing submodule' '
61 prepare_symlink_to_repo &&
62 rm -rf .git/modules &&
63 test_must_fail git checkout -f --recurse-submodules initial &&
64 test_path_is_dir a/target/.git &&
65 test_path_is_missing .git/modules/a/sm