diff mbox series

[16/22] t/t3*: merge a "grep | awk" pipeline

Message ID 20240305212533.12947-17-dev+git@drbeat.li (mailing list archive)
State Superseded
Headers show
Series avoid redundant pipelines | expand

Commit Message

Beat Bolli March 5, 2024, 9:25 p.m. UTC
Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t3920-crlf-messages.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Junio C Hamano March 6, 2024, 12:55 a.m. UTC | #1
"Beat Bolli" <bb@drbeat.li> writes:

> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  t/t3920-crlf-messages.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
> index 5eed640a6825..50ae222f0842 100755
> --- a/t/t3920-crlf-messages.sh
> +++ b/t/t3920-crlf-messages.sh
> @@ -97,7 +97,7 @@ test_expect_success 'branch: --verbose works with messages using CRLF' '
>  	git branch -v >tmp &&
>  	# Remove first two columns, and the line for the currently checked out branch
>  	current=$(git branch --show-current) &&
> -	grep -v $current <tmp | awk "{\$1=\$2=\"\"}1"  >actual &&
> +	awk "/$current/ { next } { \$1 = \$2 = \"\" } 1" <tmp >actual &&
>  	test_cmp expect actual
>  '

OK.  The original excludes any line that has $current (a branch name
without any funny letter in it) on it and sends the rest to awk.
The updated does the skipping inside the awk script.  They should be
equivalents.

Looks good.
diff mbox series

Patch

diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
index 5eed640a6825..50ae222f0842 100755
--- a/t/t3920-crlf-messages.sh
+++ b/t/t3920-crlf-messages.sh
@@ -97,7 +97,7 @@  test_expect_success 'branch: --verbose works with messages using CRLF' '
 	git branch -v >tmp &&
 	# Remove first two columns, and the line for the currently checked out branch
 	current=$(git branch --show-current) &&
-	grep -v $current <tmp | awk "{\$1=\$2=\"\"}1"  >actual &&
+	awk "/$current/ { next } { \$1 = \$2 = \"\" } 1" <tmp >actual &&
 	test_cmp expect actual
 '