3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='Pathnames with funny characters.
8 This test tries pathnames with funny characters in the working
9 tree, index, and tree objects.
15 p1
='tabs ," (dq) and spaces'
18 test_expect_success
'setup' '
20 1. A quick brown fox jumps over the lazy cat, oops dog.
21 2. A quick brown fox jumps over the lazy cat, oops dog.
22 3. A quick brown fox jumps over the lazy cat, oops dog.
25 { cat "$p0" >"$p1" || :; } &&
26 { echo "Foo Bar Baz" >"$p2" || :; } &&
28 if test -f "$p1" && cmp "$p0" "$p1"
30 test_set_prereq TABS_IN_FILENAMES
34 if ! test_have_prereq TABS_IN_FILENAMES
36 # since FAT/NTFS does not allow tabs in filenames, skip this test
37 skip_all
='Your filesystem does not allow tabs in filenames'
41 test_expect_success
'setup: populate index and tree' '
42 git update-index --add "$p0" "$p2" &&
46 test_expect_success
'ls-files prints space in filename verbatim' '
47 printf "%s\n" "just space" no-funny >expected &&
48 git ls-files >current &&
49 test_cmp expected current
52 test_expect_success
'setup: add funny filename' '
53 git update-index --add "$p1" &&
57 test_expect_success
'ls-files quotes funny filename' '
58 cat >expected <<-\EOF &&
61 "tabs\t,\" (dq) and spaces"
63 git ls-files >current &&
64 test_cmp expected current
67 test_expect_success
'ls-files -z does not quote funny filename' '
68 cat >expected <<-\EOF &&
71 tabs ," (dq) and spaces
73 git ls-files -z >ls-files.z &&
74 "$PERL_PATH" -pe "y/\000/\012/" <ls-files.z >current &&
75 test_cmp expected current
78 test_expect_success
'ls-tree quotes funny filename' '
79 cat >expected <<-\EOF &&
82 "tabs\t,\" (dq) and spaces"
84 git ls-tree -r $t1 >ls-tree &&
85 sed -e "s/^[^ ]* //" <ls-tree >current &&
86 test_cmp expected current
89 test_expect_success
'diff-index --name-status quotes funny filename' '
90 cat >expected <<-\EOF &&
91 A "tabs\t,\" (dq) and spaces"
93 git diff-index --name-status $t0 >current &&
94 test_cmp expected current
97 test_expect_success
'diff-tree --name-status quotes funny filename' '
98 cat >expected <<-\EOF &&
99 A "tabs\t,\" (dq) and spaces"
101 git diff-tree --name-status $t0 $t1 >current &&
102 test_cmp expected current
105 test_expect_success
'diff-index -z does not quote funny filename' '
106 cat >expected <<-\EOF &&
108 tabs ," (dq) and spaces
110 git diff-index -z --name-status $t0 >diff-index.z &&
111 "$PERL_PATH" -pe "y/\000/\012/" <diff-index.z >current &&
112 test_cmp expected current
115 test_expect_success
'diff-tree -z does not quote funny filename' '
116 cat >expected <<-\EOF &&
118 tabs ," (dq) and spaces
120 git diff-tree -z --name-status $t0 $t1 >diff-tree.z &&
121 "$PERL_PATH" -pe y/\\000/\\012/ <diff-tree.z >current &&
122 test_cmp expected current
125 test_expect_success
'diff-tree --find-copies-harder quotes funny filename' '
126 cat >expected <<-\EOF &&
127 CNUM no-funny "tabs\t,\" (dq) and spaces"
129 git diff-tree -C --find-copies-harder --name-status $t0 $t1 >out &&
130 sed -e "s/^C[0-9]*/CNUM/" <out >current &&
131 test_cmp expected current
134 test_expect_success
'setup: remove unfunny index entry' '
135 git update-index --force-remove "$p0"
138 test_expect_success
'diff-tree -M quotes funny filename' '
139 cat >expected <<-\EOF &&
140 RNUM no-funny "tabs\t,\" (dq) and spaces"
142 git diff-index -M --name-status $t0 >out &&
143 sed -e "s/^R[0-9]*/RNUM/" <out >current &&
144 test_cmp expected current
147 test_expect_success
'diff-index -M -p quotes funny filename' '
148 cat >expected <<-\EOF &&
149 diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
150 similarity index NUM%
152 rename to "tabs\t,\" (dq) and spaces"
154 git diff-index -M -p $t0 >diff &&
155 sed -e "s/index [0-9]*%/index NUM%/" <diff >current &&
156 test_cmp expected current
159 test_expect_success
'setup: mode change' '
163 test_expect_success
'diff-index -M -p with mode change quotes funny filename' '
164 cat >expected <<-\EOF &&
165 diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
168 similarity index NUM%
170 rename to "tabs\t,\" (dq) and spaces"
172 git diff-index -M -p $t0 >diff &&
173 sed -e "s/index [0-9]*%/index NUM%/" <diff >current &&
174 test_cmp expected current
177 test_expect_success
'diffstat for rename quotes funny filename' '
178 cat >expected <<-\EOF &&
179 "tabs\t,\" (dq) and spaces"
180 1 file changed, 0 insertions(+), 0 deletions(-)
182 git diff-index -M -p $t0 >diff &&
183 git apply --stat <diff >diffstat &&
184 sed -e "s/|.*//" -e "s/ *\$//" <diffstat >current &&
185 test_i18ncmp expected current
188 test_expect_success
'numstat for rename quotes funny filename' '
189 cat >expected <<-\EOF &&
190 0 0 "tabs\t,\" (dq) and spaces"
192 git diff-index -M -p $t0 >diff &&
193 git apply --numstat <diff >current &&
194 test_cmp expected current
197 test_expect_success
'numstat without -M quotes funny filename' '
198 cat >expected <<-\EOF &&
200 3 0 "tabs\t,\" (dq) and spaces"
202 git diff-index -p $t0 >diff &&
203 git apply --numstat <diff >current &&
204 test_cmp expected current
207 test_expect_success
'numstat for non-git rename diff quotes funny filename' '
208 cat >expected <<-\EOF &&
210 3 0 "tabs\t,\" (dq) and spaces"
212 git diff-index -p $t0 >git-diff &&
213 sed -ne "/^[-+@]/p" <git-diff >diff &&
214 git apply --numstat <diff >current &&
215 test_cmp expected current