]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7417-submodule-path-url.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t7417-submodule-path-url.sh
CommitLineData
273c6149
JK
1#!/bin/sh
2
3test_description='check handling of .gitmodule path with dash'
01dc8133 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
273c6149
JK
7. ./test-lib.sh
8
0d3beb71
TB
9test_expect_success 'setup' '
10 git config --global protocol.file.allow always
11'
12
273c6149
JK
13test_expect_success 'create submodule with dash in path' '
14 git init upstream &&
15 git -C upstream commit --allow-empty -m base &&
16 git submodule add ./upstream sub &&
17 git mv sub ./-sub &&
18 git commit -m submodule
19'
20
21test_expect_success 'clone rejects unprotected dash' '
22 test_when_finished "rm -rf dst" &&
23 git clone --recurse-submodules . dst 2>err &&
6789275d 24 test_grep ignoring err
273c6149
JK
25'
26
1a7fd1fb
JK
27test_expect_success 'fsck rejects unprotected dash' '
28 test_when_finished "rm -rf dst" &&
29 git init --bare dst &&
30 git -C dst config transfer.fsckObjects true &&
31 test_must_fail git push dst HEAD 2>err &&
32 grep gitmodulesPath err
33'
34
d2c84dad
JS
35test_expect_success MINGW 'submodule paths disallows trailing spaces' '
36 git init super &&
37 test_must_fail git -C super submodule add ../upstream "sub " &&
38
39 : add "sub", then rename "sub" to "sub ", the hard way &&
40 git -C super submodule add ../upstream sub &&
41 tree=$(git -C super write-tree) &&
42 git -C super ls-tree $tree >tree &&
43 sed "s/sub/sub /" <tree >tree.new &&
44 tree=$(git -C super mktree <tree.new) &&
45 commit=$(echo with space | git -C super commit-tree $tree) &&
01dc8133 46 git -C super update-ref refs/heads/main $commit &&
d2c84dad
JS
47
48 test_must_fail git clone --recurse-submodules super dst 2>err &&
6789275d 49 test_grep "sub " err
d2c84dad
JS
50'
51
273c6149 52test_done