setup: merge configuration of repository formats
[git/gitster.git] / t / t7417-submodule-path-url.sh
blobdbbb3853dc08537abdd482eb3f92e2bd44cceb45
1 #!/bin/sh
3 test_description='check handling of .gitmodule path with dash'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 test_expect_success 'setup' '
11 git config --global protocol.file.allow always
14 test_expect_success 'create submodule with dash in path' '
15 git init upstream &&
16 git -C upstream commit --allow-empty -m base &&
17 git submodule add ./upstream sub &&
18 git mv sub ./-sub &&
19 git commit -m submodule
22 test_expect_success 'clone rejects unprotected dash' '
23 test_when_finished "rm -rf dst" &&
24 git clone --recurse-submodules . dst 2>err &&
25 test_grep ignoring err
28 test_expect_success 'fsck rejects unprotected dash' '
29 test_when_finished "rm -rf dst" &&
30 git init --bare dst &&
31 git -C dst config transfer.fsckObjects true &&
32 test_must_fail git push dst HEAD 2>err &&
33 grep gitmodulesPath err
36 test_expect_success MINGW 'submodule paths disallows trailing spaces' '
37 git init super &&
38 test_must_fail git -C super submodule add ../upstream "sub " &&
40 : add "sub", then rename "sub" to "sub ", the hard way &&
41 git -C super submodule add ../upstream sub &&
42 tree=$(git -C super write-tree) &&
43 git -C super ls-tree $tree >tree &&
44 sed "s/sub/sub /" <tree >tree.new &&
45 tree=$(git -C super mktree <tree.new) &&
46 commit=$(echo with space | git -C super commit-tree $tree) &&
47 git -C super update-ref refs/heads/main $commit &&
49 test_must_fail git clone --recurse-submodules super dst 2>err &&
50 test_grep "sub " err
53 test_done