Subject: Re: [PATCH 1/7] Redirect grep's stderr top null too.

From: Đoàn Trần Công Danh <[email-masked]>
Date: Mon, 18 May 2020 22:30:25 +0700

On 2020-05-19 00:29:47+1000, Darren Tucker <[email-masked]> wrote:
> On Tue, 19 May 2020 at 00:13, Đoàn Trần Công Danh <[email-masked]> wrote:
> >
> > Hi Darren,
> >
> > On 2020-05-18 20:03:50+1000, Darren Tucker <[email-masked]> wrote:
> > > Prevents pollution of configure output on platforms that don't have
> > > grep -a.
> >
> > From your other's patch, I think you're in HP-UX,
> 
> Yes (it's not my usual platform but I had occasion to test something
> on it so revived an old system).
> 
> > would you mind also run the test.
> >
> > Since t5703 also uses "grep -a"
> 
> It fails with:
> $ ./t5703-upload-pack-ref-in-want.sh
> sed: There are too many commands for the s/\n// function.

I think this was introduced at 878f988350 (t/test-lib: teach
--chain-lint to detect broken &&-chains in subshells, 2018-07-11)

The chainlint.sed is too complicated for a mortal like me to
understand, I added Eric to Cc.

> ok 1 - setup repository
> sed: There are too many commands for the s/\n// function.
> not ok 2 - config controls ref-in-want advertisement
> #
> #               test-tool serve-v2 --advertise-capabilities >out &&
> #               ! grep -a ref-in-want out &&
> #
> #               git config uploadpack.allowRefInWant false &&
> #               test-tool serve-v2 --advertise-capabilities >out &&
> #               ! grep -a ref-in-want out &&
> #
> #               git config uploadpack.allowRefInWant true &&
> #               test-tool serve-v2 --advertise-capabilities >out &&
> #               grep -a ref-in-want out

I'm thinking about:
-----------8<------------
diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh
index a34460f7d8..92ad5eeec0 100755
--- a/t/t5703-upload-pack-ref-in-want.sh
+++ b/t/t5703-upload-pack-ref-in-want.sh
@@ -49,15 +49,18 @@ test_expect_success 'setup repository' '
 
 test_expect_success 'config controls ref-in-want advertisement' '
 	test-tool serve-v2 --advertise-capabilities >out &&
-	! grep -a ref-in-want out &&
+	perl -ne "/ref-in-want/ and print" out >out.filter &&
+	test_must_be_empty out.filter &&
 
 	git config uploadpack.allowRefInWant false &&
 	test-tool serve-v2 --advertise-capabilities >out &&
-	! grep -a ref-in-want out &&
+	perl -ne "/ref-in-want/ and print" out >out.filter &&
+	test_must_be_empty out.filter &&
 
 	git config uploadpack.allowRefInWant true &&
 	test-tool serve-v2 --advertise-capabilities >out &&
-	grep -a ref-in-want out
+	perl -ne "/ref-in-want/ and print" out >out.filter &&
+	test_file_not_empty out.filter
 '
 
 test_expect_success 'invalid want-ref line' '
------------------->8-----------

> #
> sed: There are too many commands for the s/\n// function.
> ok 3 - invalid want-ref line
> sed: There are too many commands for the s/\n// function.
> ok 4 - basic want-ref
> sed: There are too many commands for the s/\n// function.
> ok 5 - multiple want-ref lines
> sed: There are too many commands for the s/\n// function.
> ok 6 - mix want and want-ref
> sed: There are too many commands for the s/\n// function.
> ok 7 - want-ref with ref we already have commit for
> sed: There are too many commands for the s/\n// function.
> FATAL: Unexpected exit with code 0
> 
> If I use gnu sed and native grep, only #2 fails as above.  If I use
> gnu grep and gnu sed it passes with a warning from (gnu) printf:
> $ ./t5703-upload-pack-ref-in-want.sh
> printf: \3: invalid escape

Look like HP-UX's printf doesn't understand octal escape.
This may be a problem, since we've a patch to fix git-bisect's replace
for Windows, which is using "printf \015"
Cc-ing Junio for checking.

-- 
Danh