Jeff King | 273c614 | 2018-09-24 04:39:55 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='check handling of .gitmodule path with dash' |
Johannes Schindelin | 01dc813 | 2020-11-18 23:44:39 +0000 | [diff] [blame] | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 6 | |
Jeff King | 273c614 | 2018-09-24 04:39:55 -0400 | [diff] [blame] | 7 | . ./test-lib.sh |
| 8 | |
| 9 | test_expect_success 'create submodule with dash in path' ' |
| 10 | git init upstream && |
| 11 | git -C upstream commit --allow-empty -m base && |
| 12 | git submodule add ./upstream sub && |
| 13 | git mv sub ./-sub && |
| 14 | git commit -m submodule |
| 15 | ' |
| 16 | |
| 17 | test_expect_success 'clone rejects unprotected dash' ' |
| 18 | test_when_finished "rm -rf dst" && |
| 19 | git clone --recurse-submodules . dst 2>err && |
| 20 | test_i18ngrep ignoring err |
| 21 | ' |
| 22 | |
Jeff King | 1a7fd1f | 2018-09-24 04:42:19 -0400 | [diff] [blame] | 23 | test_expect_success 'fsck rejects unprotected dash' ' |
| 24 | test_when_finished "rm -rf dst" && |
| 25 | git init --bare dst && |
| 26 | git -C dst config transfer.fsckObjects true && |
| 27 | test_must_fail git push dst HEAD 2>err && |
| 28 | grep gitmodulesPath err |
| 29 | ' |
| 30 | |
Johannes Schindelin | d2c84da | 2019-09-05 13:27:53 +0200 | [diff] [blame] | 31 | test_expect_success MINGW 'submodule paths disallows trailing spaces' ' |
| 32 | git init super && |
| 33 | test_must_fail git -C super submodule add ../upstream "sub " && |
| 34 | |
| 35 | : add "sub", then rename "sub" to "sub ", the hard way && |
| 36 | git -C super submodule add ../upstream sub && |
| 37 | tree=$(git -C super write-tree) && |
| 38 | git -C super ls-tree $tree >tree && |
| 39 | sed "s/sub/sub /" <tree >tree.new && |
| 40 | tree=$(git -C super mktree <tree.new) && |
| 41 | commit=$(echo with space | git -C super commit-tree $tree) && |
Johannes Schindelin | 01dc813 | 2020-11-18 23:44:39 +0000 | [diff] [blame] | 42 | git -C super update-ref refs/heads/main $commit && |
Johannes Schindelin | d2c84da | 2019-09-05 13:27:53 +0200 | [diff] [blame] | 43 | |
| 44 | test_must_fail git clone --recurse-submodules super dst 2>err && |
| 45 | test_i18ngrep "sub " err |
| 46 | ' |
| 47 | |
Jeff King | 273c614 | 2018-09-24 04:39:55 -0400 | [diff] [blame] | 48 | test_done |