]>
Commit | Line | Data |
---|---|---|
4d2060ef JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='Pathnames with funny characters. | |
7 | ||
8 | This test tries pathnames with funny characters in the working | |
9 | tree, index, and tree objects. | |
10 | ' | |
11 | ||
12 | . ./test-lib.sh | |
13 | ||
46d98476 RJ |
14 | HT=' ' |
15 | ||
16 | echo 2>/dev/null > "Name with an${HT}HT" | |
17 | if ! test -f "Name with an${HT}HT" | |
18 | then | |
19 | # since FAT/NTFS does not allow tabs in filenames, skip this test | |
20 | skip_all='Your filesystem does not allow tabs in filenames' | |
21 | test_done | |
22 | fi | |
23 | ||
4d2060ef | 24 | p0='no-funny' |
73ab46d6 | 25 | p1='tabs ," (dq) and spaces' |
508c1d1c | 26 | p2='just space' |
4d2060ef | 27 | |
ef7db193 JN |
28 | test_expect_success 'setup' ' |
29 | cat >"$p0" <<-\EOF && | |
30 | 1. A quick brown fox jumps over the lazy cat, oops dog. | |
31 | 2. A quick brown fox jumps over the lazy cat, oops dog. | |
32 | 3. A quick brown fox jumps over the lazy cat, oops dog. | |
33 | EOF | |
34 | ||
35 | { cat "$p0" >"$p1" || :; } && | |
46d98476 | 36 | { echo "Foo Bar Baz" >"$p2" || :; } |
ef7db193 | 37 | ' |
4d2060ef | 38 | |
ef7db193 JN |
39 | test_expect_success 'setup: populate index and tree' ' |
40 | git update-index --add "$p0" "$p2" && | |
41 | t0=$(git write-tree) | |
42 | ' | |
e1697cc5 | 43 | |
ef7db193 JN |
44 | test_expect_success 'ls-files prints space in filename verbatim' ' |
45 | printf "%s\n" "just space" no-funny >expected && | |
5be60078 | 46 | git ls-files >current && |
ef7db193 JN |
47 | test_cmp expected current |
48 | ' | |
4d2060ef | 49 | |
ef7db193 JN |
50 | test_expect_success 'setup: add funny filename' ' |
51 | git update-index --add "$p1" && | |
52 | t1=$(git write-tree) | |
e1697cc5 ÆAB |
53 | ' |
54 | ||
ef7db193 JN |
55 | test_expect_success 'ls-files quotes funny filename' ' |
56 | cat >expected <<-\EOF && | |
57 | just space | |
58 | no-funny | |
59 | "tabs\t,\" (dq) and spaces" | |
60 | EOF | |
5be60078 | 61 | git ls-files >current && |
ef7db193 JN |
62 | test_cmp expected current |
63 | ' | |
4d2060ef | 64 | |
ef7db193 JN |
65 | test_expect_success 'ls-files -z does not quote funny filename' ' |
66 | cat >expected <<-\EOF && | |
67 | just space | |
68 | no-funny | |
69 | tabs ," (dq) and spaces | |
70 | EOF | |
71 | git ls-files -z >ls-files.z && | |
94221d22 | 72 | perl -pe "y/\000/\012/" <ls-files.z >current && |
ef7db193 JN |
73 | test_cmp expected current |
74 | ' | |
4d2060ef | 75 | |
ef7db193 JN |
76 | test_expect_success 'ls-tree quotes funny filename' ' |
77 | cat >expected <<-\EOF && | |
78 | just space | |
79 | no-funny | |
80 | "tabs\t,\" (dq) and spaces" | |
e7a8ac38 | 81 | EOF |
ef7db193 JN |
82 | git ls-tree -r $t1 >ls-tree && |
83 | sed -e "s/^[^ ]* //" <ls-tree >current && | |
84 | test_cmp expected current | |
85 | ' | |
e7a8ac38 | 86 | |
ef7db193 JN |
87 | test_expect_success 'diff-index --name-status quotes funny filename' ' |
88 | cat >expected <<-\EOF && | |
89 | A "tabs\t,\" (dq) and spaces" | |
90 | EOF | |
91 | git diff-index --name-status $t0 >current && | |
92 | test_cmp expected current | |
e1697cc5 ÆAB |
93 | ' |
94 | ||
ef7db193 JN |
95 | test_expect_success 'diff-tree --name-status quotes funny filename' ' |
96 | cat >expected <<-\EOF && | |
97 | A "tabs\t,\" (dq) and spaces" | |
98 | EOF | |
99 | git diff-tree --name-status $t0 $t1 >current && | |
100 | test_cmp expected current | |
101 | ' | |
102 | ||
103 | test_expect_success 'diff-index -z does not quote funny filename' ' | |
104 | cat >expected <<-\EOF && | |
105 | A | |
106 | tabs ," (dq) and spaces | |
107 | EOF | |
108 | git diff-index -z --name-status $t0 >diff-index.z && | |
94221d22 | 109 | perl -pe "y/\000/\012/" <diff-index.z >current && |
ef7db193 JN |
110 | test_cmp expected current |
111 | ' | |
112 | ||
113 | test_expect_success 'diff-tree -z does not quote funny filename' ' | |
114 | cat >expected <<-\EOF && | |
115 | A | |
116 | tabs ," (dq) and spaces | |
117 | EOF | |
118 | git diff-tree -z --name-status $t0 $t1 >diff-tree.z && | |
94221d22 | 119 | perl -pe y/\\000/\\012/ <diff-tree.z >current && |
ef7db193 JN |
120 | test_cmp expected current |
121 | ' | |
122 | ||
123 | test_expect_success 'diff-tree --find-copies-harder quotes funny filename' ' | |
124 | cat >expected <<-\EOF && | |
125 | CNUM no-funny "tabs\t,\" (dq) and spaces" | |
126 | EOF | |
127 | git diff-tree -C --find-copies-harder --name-status $t0 $t1 >out && | |
128 | sed -e "s/^C[0-9]*/CNUM/" <out >current && | |
129 | test_cmp expected current | |
130 | ' | |
4d2060ef | 131 | |
ef7db193 JN |
132 | test_expect_success 'setup: remove unfunny index entry' ' |
133 | git update-index --force-remove "$p0" | |
134 | ' | |
135 | ||
136 | test_expect_success 'diff-tree -M quotes funny filename' ' | |
137 | cat >expected <<-\EOF && | |
138 | RNUM no-funny "tabs\t,\" (dq) and spaces" | |
139 | EOF | |
140 | git diff-index -M --name-status $t0 >out && | |
141 | sed -e "s/^R[0-9]*/RNUM/" <out >current && | |
142 | test_cmp expected current | |
143 | ' | |
144 | ||
145 | test_expect_success 'diff-index -M -p quotes funny filename' ' | |
146 | cat >expected <<-\EOF && | |
147 | diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" | |
148 | similarity index NUM% | |
149 | rename from no-funny | |
150 | rename to "tabs\t,\" (dq) and spaces" | |
151 | EOF | |
152 | git diff-index -M -p $t0 >diff && | |
153 | sed -e "s/index [0-9]*%/index NUM%/" <diff >current && | |
154 | test_cmp expected current | |
155 | ' | |
156 | ||
157 | test_expect_success 'setup: mode change' ' | |
158 | chmod +x "$p1" | |
159 | ' | |
160 | ||
161 | test_expect_success 'diff-index -M -p with mode change quotes funny filename' ' | |
162 | cat >expected <<-\EOF && | |
163 | diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" | |
164 | old mode 100644 | |
165 | new mode 100755 | |
166 | similarity index NUM% | |
167 | rename from no-funny | |
168 | rename to "tabs\t,\" (dq) and spaces" | |
169 | EOF | |
170 | git diff-index -M -p $t0 >diff && | |
171 | sed -e "s/index [0-9]*%/index NUM%/" <diff >current && | |
172 | test_cmp expected current | |
173 | ' | |
174 | ||
175 | test_expect_success 'diffstat for rename quotes funny filename' ' | |
176 | cat >expected <<-\EOF && | |
177 | "tabs\t,\" (dq) and spaces" | |
178 | 1 file changed, 0 insertions(+), 0 deletions(-) | |
179 | EOF | |
180 | git diff-index -M -p $t0 >diff && | |
181 | git apply --stat <diff >diffstat && | |
182 | sed -e "s/|.*//" -e "s/ *\$//" <diffstat >current && | |
183 | test_i18ncmp expected current | |
184 | ' | |
185 | ||
186 | test_expect_success 'numstat for rename quotes funny filename' ' | |
187 | cat >expected <<-\EOF && | |
188 | 0 0 "tabs\t,\" (dq) and spaces" | |
189 | EOF | |
190 | git diff-index -M -p $t0 >diff && | |
191 | git apply --numstat <diff >current && | |
192 | test_cmp expected current | |
193 | ' | |
194 | ||
195 | test_expect_success 'numstat without -M quotes funny filename' ' | |
196 | cat >expected <<-\EOF && | |
197 | 0 3 no-funny | |
198 | 3 0 "tabs\t,\" (dq) and spaces" | |
199 | EOF | |
200 | git diff-index -p $t0 >diff && | |
201 | git apply --numstat <diff >current && | |
202 | test_cmp expected current | |
203 | ' | |
204 | ||
205 | test_expect_success 'numstat for non-git rename diff quotes funny filename' ' | |
206 | cat >expected <<-\EOF && | |
207 | 0 3 no-funny | |
208 | 3 0 "tabs\t,\" (dq) and spaces" | |
209 | EOF | |
210 | git diff-index -p $t0 >git-diff && | |
211 | sed -ne "/^[-+@]/p" <git-diff >diff && | |
212 | git apply --numstat <diff >current && | |
213 | test_cmp expected current | |
214 | ' | |
4d2060ef JH |
215 | |
216 | test_done |