Hi, On Sun, 22 Mar 2020, Đoàn Trần Công Danh wrote: > POSIX's diff(1) requires output in normal diff format. > However, busybox's diff's output is written in unified format. > > POSIX requires no option for normal-diff format. > > A hint in test-lib-functions::test_cmp said `diff -u` isn't available > everywhere. > > Workaround this problem by assuming `diff(1)` output is unified > if we couldn't make anything from normal-diff format. > > Signed-off-by: Đoàn Trần Công Danh <congdanhqx@xxxxxxxxx> > --- > t/t4124-apply-ws-rule.sh | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh > index 971a5a7512..075b1912be 100755 > --- a/t/t4124-apply-ws-rule.sh > +++ b/t/t4124-apply-ws-rule.sh > @@ -52,6 +52,12 @@ test_fix () { > > # find touched lines > $DIFF file target | sed -n -e "s/^> //p" >fixed > + # busybox's diff(1) output unified format > + if ! test -s fixed; then > + $DIFF file target | > + grep -v '^+++ target' | > + sed -e "/^+/s/+//" >fixed > + fi In my patches (which are too unpolished to contribute, I have not found time to clean them up in several years), I do this differently: -- snip -- commit cb2f3a28dbf40b92d3d9ca0f3177cd5afb7c4196 Author: Johannes Schindelin <Johannes.Schindelin@xxxxxx> Date: Wed Jul 5 22:21:57 2017 +0200 t4124: avoid using "normal" diff mode Everybody and their dogs, cats and other pets settled on using unified diffs. It is a really quaint holdover from a long-gone era that GNU diff outputs "normal" diff by default. Yet, t4124 relied on that mode. This mode is so out of fashion in the meantime, though, that e.g. BusyBox' diff decided not even to bother to support it. It only supports unified diffs. So let's just switch away from "normal" diffs and use unified diffs, as we really are only interested in the `+` lines. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 971a5a7512ac..133557b99333 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -51,7 +51,7 @@ test_fix () { apply_patch --whitespace=fix || return 1 # find touched lines - $DIFF file target | sed -n -e "s/^> //p" >fixed + $DIFF -u file target | sed -n -e "3,\$s/^+//p" >fixed # the changed lines are all expected to change fixed_cnt=$(wc -l <fixed) -- snap -- Food for thought? Ciao, Dscho > > # the changed lines are all expected to change > fixed_cnt=$(wc -l <fixed) > -- > 2.26.0.rc2.310.g2932bb562d > > >