Subject: Re: [PATCH v2] t3700: avoid hidden failures and use test_grep helper

From: Junio C Hamano <[email-masked]>
Date: Mon, 02 Mar 2026 13:24:28 -0800

Siddharth Shrimali <[email-masked]> writes:

> Replace pipelines involving git commands with temporary files to ensure
> that any crashes or unexpected exit codes from the git commands are
> properly caught by the test suite. A simple pipeline like
> 'git foo | grep bar' ignores the exit code of 'git', which can
> hide regressions.
>
> Additionally, replace standard 'grep' with the 'test_grep' helper.
> This improves debuggability by automatically dumping the contents of
> the 'actual' file when a match is not found. In cases where we were
> counting lines with 'wc -l' to ensure a pattern was absent,
> simplify to 'test_grep !'.

Counting the instances of these changes, there are too many hunks
that fall into this "Additionally" category to consider them "while
at it" changes.  In other words, this would want to become two
patches, one to break pipelines to expose the exit status of Git
that is upstream of a pipeline, and the other to use test_grep where
the original used grep.

>
> Suggested-by: Junio C Hamano <[email-masked]>
>
> Signed-off-by: Siddharth Shrimali <[email-masked]>

The trailer block does not allow blanks inside it.  Remove the blank
line.

> @@ -544,9 +544,11 @@ test_expect_success 'all statuses changed in folder if . is given' '
>  		touch x y z sub/a sub/dir/b &&
>  		git add -A &&
>  		git add --chmod=+x . &&
> -		test $(git ls-files --stage >actual && grep ^100644 actual | wc -l) -eq 0 &&
> +		git ls-files --stage >actual &&
> +		test_grep ! "^100644" actual &&
>  		git add --chmod=-x . &&
> -		test $(git ls-files --stage >actual && grep ^100755 actual | wc -l) -eq 0
> +		git ls-files --stage >actual &&
> +		test_grep ! "^100755" actual
>  	)
>  '
>  
> @@ -582,4 +584,4 @@ test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
>  	git add "$downcased"
>  '
>  
> -test_done
> \ No newline at end of file
> +test_done

Wait.  What tree state is this patch meant to apply?  If you made a
botched change in an earlier attempt, your "v2" patch should *not*
be relative to the tree state _with_ that botched attempt.  It
should instead be a change relative to somewhere stable in my tree,
pretending as if your "v1" (which introduced an incomplete line to
this file, among possibly other changes) never happened.

So, I'd suggest a two-patch series that is:

 - refine your v1 to remove mistakes (like the "incomplete last
   line"; there might have been others but I do not remember),
   keeping your conversion to break pipelines, without changing
   "grep" to "test_grep".  Make it [PATCH v2 1/2].

 - turn "grep" you touched in [PATCH v2 1/2] above to use
   "test_grep" instead.  In this patch, if the parts of the file you
   did not touch in [PATCH v2 1/2] has only small number of similar
   uses of "grep" that is better written with "test_grep", it is OK
   to change them to use "test_grep" as a "while at it" change.

Thanks.