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