@@ -13,6 +13,10 @@ s40=' '
1313sss=" $s40$s40$s40$s40$s40$s40$s40$s40$s40$s40 " # 400
1414ttt=" $t40$t40$t40$t40$t40$t40$t40$t40$t40$t40 " # 400
1515
16+ printf_git_stripspace () {
17+ printf " $1 " | git stripspace
18+ }
19+
1620test_expect_success \
1721 ' long lines without spaces should be unchanged' '
1822 echo "$ttt" >expect &&
@@ -225,32 +229,38 @@ test_expect_success \
225229
226230test_expect_success \
227231 ' 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"
232236'
233237
234238# text plus spaces at the end:
235239
236240test_expect_success \
237241 ' 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"
244248'
245249
246250test_expect_success \
247251 ' 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
254264'
255265
256266test_expect_success \
@@ -282,12 +292,18 @@ test_expect_success \
282292
283293test_expect_success \
284294 ' 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
291307'
292308
293309test_expect_success \
@@ -339,11 +355,16 @@ test_expect_success \
339355
340356test_expect_success \
341357 ' 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
347368'
348369
349370test_expect_success \
0 commit comments