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