setup: sanitize absolute and funny paths in get_pathspec()
[git/debian.git] / t / t7010-setup.sh
blobda20ba514afb219fe044ead51f43d3c2ce0aac1e
1 #!/bin/sh
3 test_description='setup taking and sanitizing funny paths'
5 . ./test-lib.sh
7 test_expect_success setup '
9 mkdir -p a/b/c a/e &&
10 D=$(pwd) &&
11 >a/b/c/d &&
12 >a/e/f
16 test_expect_success 'git add (absolute)' '
18 git add "$D/a/b/c/d" &&
19 git ls-files >current &&
20 echo a/b/c/d >expect &&
21 diff -u expect current
26 test_expect_success 'git add (funny relative)' '
28 rm -f .git/index &&
30 cd a/b &&
31 git add "../e/./f"
32 ) &&
33 git ls-files >current &&
34 echo a/e/f >expect &&
35 diff -u expect current
39 test_expect_success 'git rm (absolute)' '
41 rm -f .git/index &&
42 git add a &&
43 git rm -f --cached "$D/a/b/c/d" &&
44 git ls-files >current &&
45 echo a/e/f >expect &&
46 diff -u expect current
50 test_expect_success 'git rm (funny relative)' '
52 rm -f .git/index &&
53 git add a &&
55 cd a/b &&
56 git rm -f --cached "../e/./f"
57 ) &&
58 git ls-files >current &&
59 echo a/b/c/d >expect &&
60 diff -u expect current
64 test_expect_success 'git ls-files (absolute)' '
66 rm -f .git/index &&
67 git add a &&
68 git ls-files "$D/a/e/../b" >current &&
69 echo a/b/c/d >expect &&
70 diff -u expect current
74 test_expect_success 'git ls-files (relative #1)' '
76 rm -f .git/index &&
77 git add a &&
79 cd a/b &&
80 git ls-files "../b/c"
81 ) >current &&
82 echo c/d >expect &&
83 diff -u expect current
87 test_expect_success 'git ls-files (relative #2)' '
89 rm -f .git/index &&
90 git add a &&
92 cd a/b &&
93 git ls-files --full-name "../e/f"
94 ) >current &&
95 echo a/e/f >expect &&
96 diff -u expect current
100 test_expect_success 'git ls-files (relative #3)' '
102 rm -f .git/index &&
103 git add a &&
105 cd a/b &&
106 if git ls-files "../e/f"
107 then
108 echo Gaah, should have failed
109 exit 1
110 else
111 : happy
117 test_done