@@ -13,6 +13,10 @@ s40=' '
13
13
sss=" $s40$s40$s40$s40$s40$s40$s40$s40$s40$s40 " # 400
14
14
ttt=" $t40$t40$t40$t40$t40$t40$t40$t40$t40$t40 " # 400
15
15
16
+ printf_git_stripspace () {
17
+ printf " $1 " | git stripspace
18
+ }
19
+
16
20
test_expect_success \
17
21
' long lines without spaces should be unchanged' '
18
22
echo "$ttt" >expect &&
@@ -225,32 +229,38 @@ test_expect_success \
225
229
226
230
test_expect_success \
227
231
' text without newline at end should end with newline' '
228
- test $(printf "$ttt" | git stripspace | wc -l) -gt 0 &&
229
- test $(printf "$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
230
- test $(printf "$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
231
- test $(printf "$ttt$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0
232
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt" &&
233
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt" &&
234
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt" &&
235
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$ttt"
232
236
'
233
237
234
238
# text plus spaces at the end:
235
239
236
240
test_expect_success \
237
241
' text plus spaces without newline at end should end with newline' '
238
- test $(printf "$ttt$sss" | git stripspace | wc -l) -gt 0 &&
239
- test $(printf "$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
240
- test $(printf "$ttt$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
241
- test $(printf "$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
242
- test $(printf "$ttt$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
243
- test $(printf "$ttt$sss$sss$sss" | git stripspace | wc -l) -gt 0
242
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss" &&
243
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss" &&
244
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$sss" &&
245
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss" &&
246
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss$sss" &&
247
+ test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss$sss"
244
248
'
245
249
246
250
test_expect_success \
247
251
' text plus spaces without newline at end should not show spaces' '
248
- ! (printf "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
249
- ! (printf "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
250
- ! (printf "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
251
- ! (printf "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
252
- ! (printf "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
253
- ! (printf "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
252
+ printf "$ttt$sss" | git stripspace >tmp &&
253
+ ! grep " " tmp >/dev/null &&
254
+ printf "$ttt$ttt$sss" | git stripspace >tmp &&
255
+ ! grep " " tmp >/dev/null &&
256
+ printf "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
257
+ ! grep " " tmp >/dev/null &&
258
+ printf "$ttt$sss$sss" | git stripspace >tmp &&
259
+ ! grep " " tmp >/dev/null &&
260
+ printf "$ttt$ttt$sss$sss" | git stripspace >tmp &&
261
+ ! grep " " tmp >/dev/null &&
262
+ printf "$ttt$sss$sss$sss" | git stripspace >tmp &&
263
+ ! grep " " tmp >/dev/null
254
264
'
255
265
256
266
test_expect_success \
@@ -282,12 +292,18 @@ test_expect_success \
282
292
283
293
test_expect_success \
284
294
' text plus spaces at end should not show spaces' '
285
- ! (echo "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
286
- ! (echo "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
287
- ! (echo "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
288
- ! (echo "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
289
- ! (echo "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
290
- ! (echo "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
295
+ echo "$ttt$sss" | git stripspace >tmp &&
296
+ ! grep " " tmp >/dev/null &&
297
+ echo "$ttt$ttt$sss" | git stripspace >tmp &&
298
+ ! grep " " tmp >/dev/null &&
299
+ echo "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
300
+ ! grep " " tmp >/dev/null &&
301
+ echo "$ttt$sss$sss" | git stripspace >tmp &&
302
+ ! grep " " tmp >/dev/null &&
303
+ echo "$ttt$ttt$sss$sss" | git stripspace >tmp &&
304
+ ! grep " " tmp >/dev/null &&
305
+ echo "$ttt$sss$sss$sss" | git stripspace >tmp &&
306
+ ! grep " " tmp >/dev/null
291
307
'
292
308
293
309
test_expect_success \
@@ -339,11 +355,16 @@ test_expect_success \
339
355
340
356
test_expect_success \
341
357
' spaces without newline at end should not show spaces' '
342
- ! (printf "" | git stripspace | grep " " >/dev/null) &&
343
- ! (printf "$sss" | git stripspace | grep " " >/dev/null) &&
344
- ! (printf "$sss$sss" | git stripspace | grep " " >/dev/null) &&
345
- ! (printf "$sss$sss$sss" | git stripspace | grep " " >/dev/null) &&
346
- ! (printf "$sss$sss$sss$sss" | git stripspace | grep " " >/dev/null)
358
+ printf "" | git stripspace >tmp &&
359
+ ! grep " " tmp >/dev/null &&
360
+ printf "$sss" | git stripspace >tmp &&
361
+ ! grep " " tmp >/dev/null &&
362
+ printf "$sss$sss" | git stripspace >tmp &&
363
+ ! grep " " tmp >/dev/null &&
364
+ printf "$sss$sss$sss" | git stripspace >tmp &&
365
+ ! grep " " tmp >/dev/null &&
366
+ printf "$sss$sss$sss$sss" | git stripspace >tmp &&
367
+ ! grep " " tmp >/dev/null
347
368
'
348
369
349
370
test_expect_success \
0 commit comments