@@ -60,19 +60,16 @@ run_completion ()
60
60
# 2: expected completion
61
61
test_completion ()
62
62
{
63
- test $# -gt 1 && echo " $2 " > expected
63
+ if test $# -gt 1
64
+ then
65
+ printf ' %s\n' " $2 " > expected
66
+ else
67
+ sed -e ' s/Z$//' > expected
68
+ fi &&
64
69
run_completion " $1 " &&
65
70
test_cmp expected out
66
71
}
67
72
68
- # Like test_completion, but reads expectation from stdin,
69
- # which is convenient when it is multiline.
70
- test_completion_long ()
71
- {
72
- sed -e ' s/Z$//' > expected &&
73
- test_completion " $1 "
74
- }
75
-
76
73
newline=$' \n '
77
74
78
75
test_expect_success ' __gitcomp - trailing space - options' '
@@ -172,7 +169,7 @@ test_expect_success 'basic' '
172
169
'
173
170
174
171
test_expect_success ' double dash "git" itself' '
175
- test_completion_long "git --" <<-\EOF
172
+ test_completion "git --" <<-\EOF
176
173
--paginate Z
177
174
--no-pager Z
178
175
--git-dir=
@@ -190,7 +187,7 @@ test_expect_success 'double dash "git" itself' '
190
187
'
191
188
192
189
test_expect_success ' double dash "git checkout"' '
193
- test_completion_long "git checkout --" <<-\EOF
190
+ test_completion "git checkout --" <<-\EOF
194
191
--quiet Z
195
192
--ours Z
196
193
--theirs Z
@@ -206,7 +203,7 @@ test_expect_success 'double dash "git checkout"' '
206
203
test_expect_success ' general options' '
207
204
test_completion "git --ver" "--version " &&
208
205
test_completion "git --hel" "--help " &&
209
- test_completion_long "git --exe" <<-\EOF &&
206
+ test_completion "git --exe" <<-\EOF &&
210
207
--exec-path Z
211
208
--exec-path=
212
209
EOF
@@ -247,23 +244,23 @@ test_expect_success 'setup for ref completion' '
247
244
'
248
245
249
246
test_expect_success ' checkout completes ref names' '
250
- test_completion_long "git checkout m" <<-\EOF
247
+ test_completion "git checkout m" <<-\EOF
251
248
master Z
252
249
mybranch Z
253
250
mytag Z
254
251
EOF
255
252
'
256
253
257
254
test_expect_success ' show completes all refs' '
258
- test_completion_long "git show m" <<-\EOF
255
+ test_completion "git show m" <<-\EOF
259
256
master Z
260
257
mybranch Z
261
258
mytag Z
262
259
EOF
263
260
'
264
261
265
262
test_expect_success ' <ref>: completes paths' '
266
- test_completion_long "git show mytag:f" <<-\EOF
263
+ test_completion "git show mytag:f" <<-\EOF
267
264
file1 Z
268
265
file2 Z
269
266
EOF
@@ -273,7 +270,7 @@ test_expect_success 'complete tree filename with spaces' '
273
270
echo content >"name with spaces" &&
274
271
git add . &&
275
272
git commit -m spaces &&
276
- test_completion_long "git show HEAD:nam" <<-\EOF
273
+ test_completion "git show HEAD:nam" <<-\EOF
277
274
name with spaces Z
278
275
EOF
279
276
'
@@ -282,7 +279,7 @@ test_expect_failure 'complete tree filename with metacharacters' '
282
279
echo content >"name with \${meta}" &&
283
280
git add . &&
284
281
git commit -m meta &&
285
- test_completion_long "git show HEAD:nam" <<-\EOF
282
+ test_completion "git show HEAD:nam" <<-\EOF
286
283
name with ${meta} Z
287
284
name with spaces Z
288
285
EOF
0 commit comments