Makefile: make NO_ICONV really mean "no iconv"
[git.git] / t / t7415-submodule-names.sh
blob75fa071c6d042aad43d3255935c1d99324073a31
1 #!/bin/sh
3 test_description='check handling of .. in submodule names
5 Exercise the name-checking function on a variety of names, and then give a
6 real-world setup that confirms we catch this in practice.
8 . ./test-lib.sh
10 test_expect_success 'check names' '
11 cat >expect <<-\EOF &&
12 valid
13 valid/with/paths
14 EOF
16 git submodule--helper check-name >actual <<-\EOF &&
17 valid
18 valid/with/paths
20 ../foo
21 /../foo
22 ..\foo
23 \..\foo
24 foo/..
25 foo/../
26 foo\..
27 foo\..\
28 foo/../bar
29 EOF
31 test_cmp expect actual
34 test_expect_success 'create innocent subrepo' '
35 git init innocent &&
36 git -C innocent commit --allow-empty -m foo
39 test_expect_success 'submodule add refuses invalid names' '
40 test_must_fail \
41 git submodule add --name ../../modules/evil "$PWD/innocent" evil
44 test_expect_success 'add evil submodule' '
45 git submodule add "$PWD/innocent" evil &&
47 mkdir modules &&
48 cp -r .git/modules/evil modules &&
49 write_script modules/evil/hooks/post-checkout <<-\EOF &&
50 echo >&2 "RUNNING POST CHECKOUT"
51 EOF
53 git config -f .gitmodules submodule.evil.update checkout &&
54 git config -f .gitmodules --rename-section \
55 submodule.evil submodule.../../modules/evil &&
56 git add modules &&
57 git commit -am evil
60 # This step seems like it shouldn't be necessary, since the payload is
61 # contained entirely in the evil submodule. But due to the vagaries of the
62 # submodule code, checking out the evil module will fail unless ".git/modules"
63 # exists. Adding another submodule (with a name that sorts before "evil") is an
64 # easy way to make sure this is the case in the victim clone.
65 test_expect_success 'add other submodule' '
66 git submodule add "$PWD/innocent" another-module &&
67 git add another-module &&
68 git commit -am another
71 test_expect_success 'clone evil superproject' '
72 git clone --recurse-submodules . victim >output 2>&1 &&
73 ! grep "RUNNING POST CHECKOUT" output
76 test_done