Merge branch 'ja/doc-synopsis-markup'
[git/gitster.git] / t / t7423-submodule-symlinks.sh
blobf45d80620185b2d791e095179f22b6a967ab097e
1 #!/bin/sh
3 test_description='check that submodule operations do not follow symlinks'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'prepare' '
9 git config --global protocol.file.allow always &&
10 test_commit initial &&
11 git init upstream &&
12 test_commit -C upstream upstream submodule_file &&
13 git submodule add ./upstream a/sm &&
14 test_tick &&
15 git commit -m submodule
18 test_expect_success SYMLINKS 'git submodule update must not create submodule behind symlink' '
19 rm -rf a b &&
20 mkdir b &&
21 ln -s b a &&
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' '
28 rm -rf a b &&
29 mkdir b &&
30 ln -s b A &&
31 test_must_fail git submodule update &&
32 test_path_is_missing b/sm
35 prepare_symlink_to_repo() {
36 rm -rf a &&
37 mkdir a &&
38 git init a/target &&
39 git -C a/target fetch ../../upstream &&
40 ln -s target a/sm
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
68 test_done