git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/22] avoid redundant pipelines
@ 2024-03-05 21:24 Beat Bolli
  2024-03-05 21:25 ` [PATCH 01/22] doc: avoid redundant use of cat Beat Bolli
                   ` (24 more replies)
  0 siblings, 25 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Beat Bolli, René Scharfe, Elijah Newren,
	Philippe Blain, Johannes Schindelin

As follow-up to [1], here's a series that eliminates redundant
pipelines, mostly under t/.

Spawning a process is notoriously slow on Windows, so this will improve
test performance.

1/22 to 14/22 remove redundant uses of "cat" where the shell handles
input redirection from a file or the command can take a file argument.

15/22 to 20/22 merge redundant uses of "grep" into the following "sed"
or "awk" command. Both of these are capable of filtering themselves. I'm
a bit on the fence about this part because readability suffers in some
cases. It was a fun exercise, though :-)

21/22 merges multiple "sed" calls into one and replaces a whole "cat |
grep | awk" construct with a single "awk" call and uses "sort -u"
instead of "sort | uniq".

22/22 finally is a bit of an outlier in that it replaces a subshell with
a shell compound command.

In the tests, I have completely arbitrarily separated the commits into
thousands blocks to keep the commits and their reviews manageable.

All tests that I was able to run still pass. I don't have p4 or cvs
installed.

[1] https://lore.kernel.org/git/20240216171046.927552-1-dev+git@drbeat.li/

Beat Bolli (22):
  doc: avoid redundant use of cat
  contrib/subtree/t: avoid redundant use of cat
  t/lib-cvs.sh: avoid redundant use of cat
  t/annotate-tests.sh: avoid redundant use of cat
  t/perf: avoid redundant use of cat
  t/t0*: avoid redundant uses of cat
  t/t1*: avoid redundant uses of cat
  t/t3*: avoid redundant uses of cat
  t/t4*: avoid redundant uses of cat
  t/t5*: avoid redundant uses of cat
  t/t6*: avoid redundant uses of cat
  t/t7*: avoid redundant use of cat
  t/t8*: avoid redundant use of cat
  t/t9*: avoid redundant uses of cat
  t/t1*: merge a "grep | sed" pipeline
  t/t3*: merge a "grep | awk" pipeline
  t/t4*: merge a "grep | sed" pipeline
  t/t5*: merge a "grep | sed" pipeline
  t/t8*: merge "grep | sed" pipelines
  t/t9*: merge "grep | sed" pipelines
  contrib/coverage-diff: avoid redundant pipelines
  git-quiltimport: avoid an unnecessary subshell

 Documentation/howto/update-hook-example.txt |  4 +--
 contrib/coverage-diff.sh                    |  9 ++----
 contrib/subtree/t/t7900-subtree.sh          |  2 +-
 git-quiltimport.sh                          |  2 +-
 t/annotate-tests.sh                         |  2 +-
 t/lib-cvs.sh                                |  4 +--
 t/perf/repos/inflate-repo.sh                |  2 +-
 t/t0002-gitfile.sh                          |  2 +-
 t/t0011-hashmap.sh                          |  2 +-
 t/t0028-working-tree-encoding.sh            |  4 +--
 t/t0204-gettext-reencode-sanity.sh          |  2 +-
 t/t1007-hash-object.sh                      |  6 ++--
 t/t1091-sparse-checkout-builtin.sh          |  2 +-
 t/t1509/prepare-chroot.sh                   |  2 +-
 t/t3200-branch.sh                           |  2 +-
 t/t3321-notes-stripspace.sh                 |  8 ++---
 t/t3920-crlf-messages.sh                    |  4 +--
 t/t4002-diff-basic.sh                       |  2 +-
 t/t4020-diff-external.sh                    |  2 +-
 t/t4150-am.sh                               |  2 +-
 t/t4205-log-pretty-formats.sh               |  2 +-
 t/t4301-merge-tree-write-tree.sh            |  8 ++---
 t/t5100-mailinfo.sh                         |  2 +-
 t/t5317-pack-objects-filter-objects.sh      |  2 +-
 t/t5401-update-hooks.sh                     |  2 +-
 t/t5534-push-signed.sh                      |  2 +-
 t/t6112-rev-list-filters-objects.sh         |  2 +-
 t/t6413-merge-crlf.sh                       |  4 +--
 t/t7704-repack-cruft.sh                     |  2 +-
 t/t8010-cat-file-filters.sh                 |  2 +-
 t/t8013-blame-ignore-revs.sh                | 28 ++++++++---------
 t/t9118-git-svn-funky-branch-names.sh       |  2 +-
 t/t9300-fast-import.sh                      | 10 +++---
 t/t9350-fast-export.sh                      |  4 +--
 t/t9400-git-cvsserver-server.sh             | 35 ++++++++++-----------
 t/t9802-git-p4-filetype.sh                  |  2 +-
 t/t9807-git-p4-submit.sh                    |  2 +-
 t/t9824-git-p4-git-lfs.sh                   |  4 +--
 38 files changed, 86 insertions(+), 94 deletions(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 78+ messages in thread

* [PATCH 01/22] doc: avoid redundant use of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 22:24   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 02/22] contrib/subtree/t: " Beat Bolli
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

The update-hook-example.txt script uses this anti-pattern twice. Call grep
with the input file name directy. While at it, merge the two consecutive
grep calls.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 Documentation/howto/update-hook-example.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/howto/update-hook-example.txt b/Documentation/howto/update-hook-example.txt
index 151ee84cebce..4e727deedd21 100644
--- a/Documentation/howto/update-hook-example.txt
+++ b/Documentation/howto/update-hook-example.txt
@@ -100,7 +100,7 @@ info "The user is: '$username'"
 
 if test -f "$allowed_users_file"
 then
-  rc=$(cat $allowed_users_file | grep -v '^#' | grep -v '^$' |
+  rc=$(grep -Ev '^(#|$)' $allowed_users_file |
     while read heads user_patterns
     do
       # does this rule apply to us?
@@ -138,7 +138,7 @@ info "'$groups'"
 
 if test -f "$allowed_groups_file"
 then
-  rc=$(cat $allowed_groups_file | grep -v '^#' | grep -v '^$' |
+  rc=$(grep -Ev '^(#|$)' $allowed_groups_file |
     while read heads group_patterns
     do
       # does this rule apply to us?
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 02/22] contrib/subtree/t: avoid redundant use of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
  2024-03-05 21:25 ` [PATCH 01/22] doc: avoid redundant use of cat Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 22:25   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 03/22] t/lib-cvs.sh: " Beat Bolli
                   ` (22 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 contrib/subtree/t/t7900-subtree.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index ca4df5be8324..c3bd2a58b941 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -63,7 +63,7 @@ test_create_pre2_32_repo () {
 	git -C "$1" log -1 --format=%B HEAD^2 >msg &&
 	test_commit -C "$1-sub" --annotate sub2 &&
 	git clone --no-local "$1" "$1-clone" &&
-	new_commit=$(cat msg | sed -e "s/$commit/$tag/" | git -C "$1-clone" commit-tree HEAD^2^{tree}) &&
+	new_commit=$(sed -e "s/$commit/$tag/" msg | git -C "$1-clone" commit-tree HEAD^2^{tree}) &&
 	git -C "$1-clone" replace HEAD^2 $new_commit
 }
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 03/22] t/lib-cvs.sh: avoid redundant use of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
  2024-03-05 21:25 ` [PATCH 01/22] doc: avoid redundant use of cat Beat Bolli
  2024-03-05 21:25 ` [PATCH 02/22] contrib/subtree/t: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 22:26   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 04/22] t/annotate-tests.sh: " Beat Bolli
                   ` (21 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/lib-cvs.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh
index 32b347337908..57b9b2db9b3f 100644
--- a/t/lib-cvs.sh
+++ b/t/lib-cvs.sh
@@ -71,8 +71,8 @@ test_cmp_branch_tree () {
 		find . -type d -name .git -prune -o -type f -print
 	) | sort >module-git-"$1".list &&
 	test_cmp module-cvs-"$1".list module-git-"$1".list &&
-	cat module-cvs-"$1".list | while read f
+	while read f
 	do
 		test_cmp_branch_file "$1" "$f" || return 1
-	done
+	done <module-cvs-"$1".list
 }
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 04/22] t/annotate-tests.sh: avoid redundant use of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (2 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 03/22] t/lib-cvs.sh: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 22:28   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 05/22] t/perf: " Beat Bolli
                   ` (20 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/annotate-tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 5e21e84f3884..87572459e4b8 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -532,7 +532,7 @@ test_expect_success 'blame -L :funcname with userdiff driver' '
 		"$(cat file.template)" &&
 	test_commit --author "B <B@test.git>" \
 		"change" "$fortran_file" \
-		"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
+		"$(sed -e s/ChangeMe/IWasChanged/ file.template)" &&
 	check_count -f "$fortran_file" -L:RIGHT A 3 B 1
 '
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 05/22] t/perf: avoid redundant use of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (3 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 04/22] t/annotate-tests.sh: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 22:29   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 06/22] t/t0*: avoid redundant uses " Beat Bolli
                   ` (19 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Take care to redirect stdin, otherwise the output of wc would also contain
the file name.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/perf/repos/inflate-repo.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/perf/repos/inflate-repo.sh b/t/perf/repos/inflate-repo.sh
index fcfc992b5b02..412e4b450b16 100755
--- a/t/perf/repos/inflate-repo.sh
+++ b/t/perf/repos/inflate-repo.sh
@@ -33,7 +33,7 @@ do
 done
 
 git ls-tree -r HEAD >GEN_src_list
-nr_src_files=$(cat GEN_src_list | wc -l)
+nr_src_files=$(wc -l <GEN_src_list)
 
 src_branch=$(git symbolic-ref --short HEAD)
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 06/22] t/t0*: avoid redundant uses of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (4 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 05/22] t/perf: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 07/22] t/t1*: " Beat Bolli
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t0002-gitfile.sh                 | 2 +-
 t/t0011-hashmap.sh                 | 2 +-
 t/t0028-working-tree-encoding.sh   | 4 ++--
 t/t0204-gettext-reencode-sanity.sh | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index 736516cc6a47..bf3bf604abe3 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -40,7 +40,7 @@ test_expect_success 'final setup + check rev-parse --git-dir' '
 
 test_expect_success 'check hash-object' '
 	echo "foo" >bar &&
-	SHA=$(cat bar | git hash-object -w --stdin) &&
+	SHA=$(git hash-object -w --stdin <bar) &&
 	test_path_is_file "$REAL/objects/$(objpath $SHA)"
 '
 
diff --git a/t/t0011-hashmap.sh b/t/t0011-hashmap.sh
index 1cb6aa682432..46e74ad1072b 100755
--- a/t/t0011-hashmap.sh
+++ b/t/t0011-hashmap.sh
@@ -239,7 +239,7 @@ test_expect_success 'grow / shrink' '
 	echo value40 >> expect &&
 	echo size >> in &&
 	echo 64 39 >> expect &&
-	cat in | test-tool hashmap > out &&
+	test-tool hashmap <in >out &&
 	test_cmp expect out
 
 '
diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh
index 1b55f59c237c..ad151a346708 100755
--- a/t/t0028-working-tree-encoding.sh
+++ b/t/t0028-working-tree-encoding.sh
@@ -131,8 +131,8 @@ do
 		test_when_finished "rm -f crlf.utf${i}.raw lf.utf${i}.raw" &&
 		test_when_finished "git reset --hard HEAD^" &&
 
-		cat lf.utf8.raw | write_utf${i} >lf.utf${i}.raw &&
-		cat crlf.utf8.raw | write_utf${i} >crlf.utf${i}.raw &&
+		write_utf${i} <lf.utf8.raw >lf.utf${i}.raw &&
+		write_utf${i} <crlf.utf8.raw >crlf.utf${i}.raw &&
 		cp crlf.utf${i}.raw eol.utf${i} &&
 
 		cat >expectIndexLF <<-EOF &&
diff --git a/t/t0204-gettext-reencode-sanity.sh b/t/t0204-gettext-reencode-sanity.sh
index 4f2e0dcb02bd..310a4500125f 100755
--- a/t/t0204-gettext-reencode-sanity.sh
+++ b/t/t0204-gettext-reencode-sanity.sh
@@ -82,7 +82,7 @@ test_expect_success GETTEXT_ISO_LOCALE 'gettext.c: git init UTF-8 -> ISO-8859-1'
     printf "Bjó til tóma Git lind" >expect &&
     LANGUAGE=is LC_ALL="$is_IS_iso_locale" git init repo >actual &&
     test_when_finished "rm -rf repo" &&
-    grep "^$(cat expect | iconv -f UTF-8 -t ISO8859-1) " actual
+    grep "^$(iconv -f UTF-8 -t ISO8859-1 <expect) " actual
 '
 
 test_done
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 07/22] t/t1*: avoid redundant uses of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (5 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 06/22] t/t0*: avoid redundant uses " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 08/22] t/t3*: " Beat Bolli
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t1007-hash-object.sh             | 6 +++---
 t/t1091-sparse-checkout-builtin.sh | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index ac3d173767ae..64aea3848606 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -124,8 +124,8 @@ test_expect_success 'check that appropriate filter is invoke when --path is used
 	path0_sha=$(git hash-object --path=file0 file1) &&
 	test "$file0_sha" = "$path0_sha" &&
 	test "$file1_sha" = "$path1_sha" &&
-	path1_sha=$(cat file0 | git hash-object --path=file1 --stdin) &&
-	path0_sha=$(cat file1 | git hash-object --path=file0 --stdin) &&
+	path1_sha=$(git hash-object --path=file1 --stdin <file0) &&
+	path0_sha=$(git hash-object --path=file0 --stdin <file1) &&
 	test "$file0_sha" = "$path0_sha" &&
 	test "$file1_sha" = "$path1_sha"
 '
@@ -154,7 +154,7 @@ test_expect_success '--path works in a subdirectory' '
 test_expect_success 'check that --no-filters option works' '
 	nofilters_file1=$(git hash-object --no-filters file1) &&
 	test "$file0_sha" = "$nofilters_file1" &&
-	nofilters_file1=$(cat file1 | git hash-object --stdin) &&
+	nofilters_file1=$(git hash-object --stdin <file1) &&
 	test "$file0_sha" = "$nofilters_file1"
 '
 
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
index e49b8024ac53..ab3a105ffff2 100755
--- a/t/t1091-sparse-checkout-builtin.sh
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -968,7 +968,7 @@ test_expect_success 'check-rules non-cone mode' '
 	git -C bare sparse-checkout check-rules --no-cone --rules-file ../rules\
 		>check-rules-file <all-files &&
 
-	cat rules | git -C repo sparse-checkout set --no-cone --stdin &&
+	git -C repo sparse-checkout set --no-cone --stdin <rules &&
 	git -C repo ls-files -t >out &&
 	sed -n "/^S /!s/^. //p" out >ls-files &&
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 08/22] t/t3*: avoid redundant uses of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (6 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 07/22] t/t1*: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 09/22] t/t4*: " Beat Bolli
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t3200-branch.sh           | 2 +-
 t/t3321-notes-stripspace.sh | 8 ++++----
 t/t3920-crlf-messages.sh    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index e36f4d15f2dd..c394273527cb 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -579,7 +579,7 @@ EOF
 
 	# ...and that the comments for those sections are also
 	# preserved.
-	cat config.branch | sed "s/\"source\"/\"dest\"/" >expect &&
+	sed "s/\"source\"/\"dest\"/" config.branch >expect &&
 	sed -n -e "/Note the lack/,\$p" .git/config >actual &&
 	test_cmp expect actual
 '
diff --git a/t/t3321-notes-stripspace.sh b/t/t3321-notes-stripspace.sh
index 088a852dd47a..beca34605672 100755
--- a/t/t3321-notes-stripspace.sh
+++ b/t/t3321-notes-stripspace.sh
@@ -442,7 +442,7 @@ test_expect_success 'add note by specifying "-C", "--no-stripspace" is the defau
 	${LF}
 	EOF
 
-	cat expect | git hash-object -w --stdin >blob &&
+	git hash-object -w --stdin <expect >blob &&
 	git notes add -C $(cat blob) &&
 	git notes show >actual &&
 	test_cmp expect actual &&
@@ -468,7 +468,7 @@ test_expect_success 'reuse note by specifying "-C" and "--stripspace"' '
 	second-line
 	EOF
 
-	cat data | git hash-object -w --stdin >blob &&
+	git hash-object -w --stdin <data >blob &&
 	git notes add --stripspace -C $(cat blob) &&
 	git notes show >actual &&
 	test_cmp expect actual
@@ -492,7 +492,7 @@ test_expect_success 'reuse with "-C" and add note with "-m", "-m" will stripspac
 	third-line
 	EOF
 
-	cat data | git hash-object -w --stdin >blob &&
+	git hash-object -w --stdin <data >blob &&
 	git notes add -C $(cat blob) -m "third-line" &&
 	git notes show >actual &&
 	test_cmp expect actual
@@ -511,7 +511,7 @@ test_expect_success 'add note with "-m" and reuse note with "-C", "-C" will not
 	second-line
 	EOF
 
-	cat data | git hash-object -w --stdin >blob &&
+	git hash-object -w --stdin <data >blob &&
 	git notes add -m "first-line" -C $(cat blob)  &&
 	git notes show >actual &&
 	test_cmp expect actual
diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
index 67fd2345affd..5eed640a6825 100755
--- a/t/t3920-crlf-messages.sh
+++ b/t/t3920-crlf-messages.sh
@@ -10,7 +10,7 @@ LIB_CRLF_BRANCHES=""
 create_crlf_ref () {
 	branch="$1" &&
 	cat >.crlf-orig-$branch.txt &&
-	cat .crlf-orig-$branch.txt | append_cr >.crlf-message-$branch.txt &&
+	append_cr <.crlf-orig-$branch.txt >.crlf-message-$branch.txt &&
 	grep 'Subject' .crlf-orig-$branch.txt | tr '\n' ' ' | sed 's/[ ]*$//' | tr -d '\n' >.crlf-subject-$branch.txt &&
 	grep 'Body' .crlf-orig-$branch.txt | append_cr >.crlf-body-$branch.txt &&
 	LIB_CRLF_BRANCHES="${LIB_CRLF_BRANCHES} ${branch}" &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 09/22] t/t4*: avoid redundant uses of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (7 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 08/22] t/t3*: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-06  0:49   ` Junio C Hamano
  2024-03-06  1:08   ` Eric Sunshine
  2024-03-05 21:25 ` [PATCH 10/22] t/t5*: " Beat Bolli
                   ` (15 subsequent siblings)
  24 siblings, 2 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t4020-diff-external.sh         | 2 +-
 t/t4150-am.sh                    | 2 +-
 t/t4205-log-pretty-formats.sh    | 2 +-
 t/t4301-merge-tree-write-tree.sh | 8 ++++----
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index c1ac09ecc714..fdd865f7c38d 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -232,7 +232,7 @@ keep_only_cr () {
 test_expect_success 'external diff with autocrlf = true' '
 	test_config core.autocrlf true &&
 	GIT_EXTERNAL_DIFF=./fake-diff.sh git diff &&
-	test $(wc -l < crlfed.txt) = $(cat crlfed.txt | keep_only_cr | wc -c)
+	test $(wc -l < crlfed.txt) = $(keep_only_cr <crlfed.txt | wc -c)
 '
 
 test_expect_success 'diff --cached' '
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 3b125762694e..080a07e9d414 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -786,7 +786,7 @@ test_expect_success 'am takes patches from a Pine mailbox' '
 	rm -fr .git/rebase-apply &&
 	git reset --hard &&
 	git checkout first &&
-	cat pine patch1 | git am &&
+	git am pine patch1 &&
 	test_path_is_missing .git/rebase-apply &&
 	git diff --exit-code main^..HEAD
 '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index e3d655e6b8b5..1409eebcd855 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -156,7 +156,7 @@ test_expect_success 'NUL termination with --reflog --pretty=oneline' '
 	for r in $revs
 	do
 		git show -s --pretty=oneline "$r" >raw &&
-		cat raw | lf_to_nul || return 1
+		lf_to_nul <raw || return 1
 	done >expect &&
 	# the trailing NUL is already produced so we do not need to
 	# output another one
diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh
index 12ac43687366..578641467753 100755
--- a/t/t4301-merge-tree-write-tree.sh
+++ b/t/t4301-merge-tree-write-tree.sh
@@ -313,7 +313,7 @@ test_expect_success 'rename/add handling' '
 		# First, check that the bar that appears at stage 3 does not
 		# correspond to an individual blob anywhere in history
 		#
-		hash=$(cat out | tr "\0" "\n" | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
+		hash=$(tr "\0" "\n" <out | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
 		git rev-list --objects --all >all_blobs &&
 		! grep $hash all_blobs &&
 
@@ -380,7 +380,7 @@ test_expect_success SYMLINKS 'rename/add, where add is a mode conflict' '
 		# First, check that the bar that appears at stage 3 does not
 		# correspond to an individual blob anywhere in history
 		#
-		hash=$(cat out | tr "\0" "\n" | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
+		hash=$(tr "\0" "\n" <out | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
 		git rev-list --objects --all >all_blobs &&
 		! grep $hash all_blobs &&
 
@@ -630,8 +630,8 @@ test_expect_success 'mod6: chains of rename/rename(1to2) and add/add via collidi
 		# conflict entries do not appear as individual blobs anywhere
 		# in history.
 		#
-		hash1=$(cat out | tr "\0" "\n" | head | grep 2.four | cut -f 2 -d " ") &&
-		hash2=$(cat out | tr "\0" "\n" | head | grep 3.two | cut -f 2 -d " ") &&
+		hash1=$(tr "\0" "\n" <out | head | grep 2.four | cut -f 2 -d " ") &&
+		hash2=$(tr "\0" "\n" <out | head | grep 3.two | cut -f 2 -d " ") &&
 		git rev-list --objects --all >all_blobs &&
 		! grep $hash1 all_blobs &&
 		! grep $hash2 all_blobs &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 10/22] t/t5*: avoid redundant uses of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (8 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 09/22] t/t4*: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 11/22] t/t6*: " Beat Bolli
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t5100-mailinfo.sh                    | 2 +-
 t/t5317-pack-objects-filter-objects.sh | 2 +-
 t/t5534-push-signed.sh                 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index 654d8cf3ee00..c8d06554541c 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -70,7 +70,7 @@ test_expect_success 'respect NULs' '
 
 	git mailsplit -d3 -o. "$DATA/nul-plain" &&
 	test_cmp "$DATA/nul-plain" 001 &&
-	(cat 001 | git mailinfo msg patch) &&
+	git mailinfo msg patch <001 &&
 	test_line_count = 4 patch
 
 '
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 2ff3eef9a3b8..79552d6ef7f6 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -455,7 +455,7 @@ test_expect_success 'setup r1 - delete loose blobs' '
 	test_parse_ls_files_stage_oids <ls_files_result |
 	sort >expected &&
 
-	for id in `cat expected | sed "s|..|&/|"`
+	for id in `sed "s|..|&/|" expected`
 	do
 		rm r1/.git/objects/$id || return 1
 	done
diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh
index b4bc24691c81..c91a62b77afc 100755
--- a/t/t5534-push-signed.sh
+++ b/t/t5534-push-signed.sh
@@ -303,7 +303,7 @@ test_expect_success GPGSM 'fail without key and heed user.signingkey x509' '
 		EOF
 		sed -n -e "s/^nonce /NONCE=/p" -e "/^$/q" dst/push-cert
 	) >expect.in &&
-	key=$(cat "${GNUPGHOME}/trustlist.txt" | cut -d" " -f1 | tr -d ":") &&
+	key=$(cut -d" " -f1 <"${GNUPGHOME}/trustlist.txt" | tr -d ":") &&
 	sed -e "s/^KEY=/KEY=${key}/" expect.in >expect &&
 
 	noop=$(git rev-parse noop) &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 11/22] t/t6*: avoid redundant uses of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (9 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 10/22] t/t5*: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 12/22] t/t7*: avoid redundant use " Beat Bolli
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t6112-rev-list-filters-objects.sh | 2 +-
 t/t6413-merge-crlf.sh               | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index 52822b9461a1..43e1afd44c9b 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -670,7 +670,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	for id in `cat expected | sed "s|..|&/|"`
+	for id in `sed "s|..|&/|" expected`
 	do
 		rm r1/.git/objects/$id || return 1
 	done &&
diff --git a/t/t6413-merge-crlf.sh b/t/t6413-merge-crlf.sh
index b4f4a313f486..647ea1e83829 100755
--- a/t/t6413-merge-crlf.sh
+++ b/t/t6413-merge-crlf.sh
@@ -34,14 +34,14 @@ test_expect_success setup '
 test_expect_success 'Check "ours" is CRLF' '
 	git reset --hard initial &&
 	git merge side -s ours &&
-	cat file | remove_cr | append_cr >file.temp &&
+	remove_cr <file | append_cr >file.temp &&
 	test_cmp file file.temp
 '
 
 test_expect_success 'Check that conflict file is CRLF' '
 	git reset --hard a &&
 	test_must_fail git merge side &&
-	cat file | remove_cr | append_cr >file.temp &&
+	remove_cr <file | append_cr >file.temp &&
 	test_cmp file file.temp
 '
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 12/22] t/t7*: avoid redundant use of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (10 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 11/22] t/t6*: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 13/22] t/t8*: " Beat Bolli
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t7704-repack-cruft.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t7704-repack-cruft.sh b/t/t7704-repack-cruft.sh
index be3735dff083..71e1ef3a103e 100755
--- a/t/t7704-repack-cruft.sh
+++ b/t/t7704-repack-cruft.sh
@@ -48,7 +48,7 @@ test_expect_success '--expire-to stores pruned objects (now)' '
 		# ...in other words, the combined contents of this
 		# repository and expired.git should be the same as the
 		# set of objects we started with.
-		cat expired.objects remaining.objects | sort >actual &&
+		sort expired.objects remaining.objects >actual &&
 		test_cmp expect actual &&
 
 		# The "moved" objects (i.e., those in expired.git)
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 13/22] t/t8*: avoid redundant use of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (11 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 12/22] t/t7*: avoid redundant use " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 14/22] t/t9*: avoid redundant uses " Beat Bolli
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t8010-cat-file-filters.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t8010-cat-file-filters.sh b/t/t8010-cat-file-filters.sh
index ca04242ca016..eb64b766bdfa 100755
--- a/t/t8010-cat-file-filters.sh
+++ b/t/t8010-cat-file-filters.sh
@@ -43,7 +43,7 @@ test_expect_success 'cat-file --textconv --path=<path> works' '
 	sha1=$(git rev-parse -q --verify HEAD:world.txt) &&
 	test_config diff.txt.textconv "tr A-Za-z N-ZA-Mn-za-m <" &&
 	git cat-file --textconv --path=hello.txt $sha1 >rot13 &&
-	test uryyb = "$(cat rot13 | remove_cr)"
+	test uryyb = "$(remove_cr <rot13)"
 '
 
 test_expect_success '--path=<path> complains without --textconv/--filters' '
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 14/22] t/t9*: avoid redundant uses of cat
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (12 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 13/22] t/t8*: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 22:52   ` Rubén Justo
  2024-03-05 21:25 ` [PATCH 15/22] t/t1*: merge a "grep | sed" pipeline Beat Bolli
                   ` (10 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t9300-fast-import.sh          | 10 +++++-----
 t/t9350-fast-export.sh          |  2 +-
 t/t9400-git-cvsserver-server.sh | 35 +++++++++++++++------------------
 t/t9802-git-p4-filetype.sh      |  2 +-
 t/t9807-git-p4-submit.sh        |  2 +-
 t/t9824-git-p4-git-lfs.sh       |  4 ++--
 6 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index dbb5042b0b8f..c03adbdd145f 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -986,7 +986,7 @@ test_expect_success 'L: nested tree copy does not corrupt deltas' '
 	test_when_finished "git update-ref -d refs/heads/L2" &&
 	git fast-import <input &&
 	git ls-tree L2 g/b/ >tmp &&
-	cat tmp | cut -f 2 >actual &&
+	cut -f 2 <tmp >actual &&
 	test_cmp expect actual &&
 	git fsck $(git rev-parse L2)
 '
@@ -2012,7 +2012,7 @@ test_expect_success 'Q: verify first notes tree' '
 	100644 blob $commit2
 	100644 blob $commit3
 	EOF
-	cat expect.unsorted | sort >expect &&
+	sort expect.unsorted >expect &&
 	git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
 	test_cmp expect actual
 '
@@ -2053,7 +2053,7 @@ test_expect_success 'Q: verify second notes tree' '
 	100644 blob $commit2
 	100644 blob $commit3
 	EOF
-	cat expect.unsorted | sort >expect &&
+	sort expect.unsorted >expect &&
 	git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
 	test_cmp expect actual
 '
@@ -2091,7 +2091,7 @@ test_expect_success 'Q: verify third notes tree' '
 	cat >expect.unsorted <<-EOF &&
 	100644 blob $commit1
 	EOF
-	cat expect.unsorted | sort >expect &&
+	sort expect.unsorted >expect &&
 	git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
 	test_cmp expect actual
 '
@@ -2118,7 +2118,7 @@ test_expect_success 'Q: verify fourth notes tree' '
 	cat >expect.unsorted <<-EOF &&
 	100644 blob $commit2
 	EOF
-	cat expect.unsorted | sort >expect &&
+	sort expect.unsorted >expect &&
 	git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
 	test_cmp expect actual
 '
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index e9a12c18bbd3..d86d07a79d4f 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -236,7 +236,7 @@ EOF
 
 test_expect_success 'set up faked signed tag' '
 
-	cat signed-tag-import | git fast-import
+	git fast-import <signed-tag-import
 
 '
 
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 003c0b61d0ff..e499c7f95512 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -117,12 +117,12 @@ END VERIFICATION REQUEST
 EOF
 
 test_expect_success 'pserver authentication' '
-	cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
+	git-cvsserver pserver <request-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'pserver authentication failure (non-anonymous user)' '
-	if cat request-git | git-cvsserver pserver >log 2>&1
+	if git-cvsserver pserver <request-git >log 2>&1
 	then
 	    false
 	else
@@ -132,17 +132,17 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' '
 '
 
 test_expect_success 'pserver authentication success (non-anonymous user with password)' '
-	cat login-git-ok | git-cvsserver pserver >log 2>&1 &&
+	git-cvsserver pserver <login-git-ok >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'pserver authentication (login)' '
-	cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
+	git-cvsserver pserver <login-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'pserver authentication failure (login/non-anonymous user)' '
-	if cat login-git | git-cvsserver pserver >log 2>&1
+	if git-cvsserver pserver <login-git >log 2>&1
 	then
 	    false
 	else
@@ -172,7 +172,7 @@ Root $WORKDIR
 EOF
 
 test_expect_success 'req_Root failure (relative pathname)' '
-	if cat request-relative | git-cvsserver pserver >log 2>&1
+	if git-cvsserver pserver <request-relative >log 2>&1
 	then
 		echo unexpected success
 		false
@@ -183,28 +183,26 @@ test_expect_success 'req_Root failure (relative pathname)' '
 '
 
 test_expect_success 'req_Root failure (conflicting roots)' '
-	cat request-conflict | git-cvsserver pserver >log 2>&1 &&
+	git-cvsserver pserver <request-conflict >log 2>&1 &&
 	tail log | grep "^error 1 Conflicting roots specified$"
 '
 
 test_expect_success 'req_Root (strict paths)' '
-	cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 &&
+	git-cvsserver --strict-paths pserver "$SERVERDIR" <request-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'req_Root failure (strict-paths)' '
-	! cat request-anonymous |
-	git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1
+	! git-cvsserver --strict-paths pserver "$WORKDIR" <request-anonymous >log 2>&1
 '
 
 test_expect_success 'req_Root (w/o strict-paths)' '
-	cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 &&
+	git-cvsserver pserver "$WORKDIR/" <request-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'req_Root failure (w/o strict-paths)' '
-	! cat request-anonymous |
-	git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1
+	! git-cvsserver pserver "$WORKDIR/gitcvs" <request-anonymous >log 2>&1
 '
 
 cat >request-base  <<EOF
@@ -217,27 +215,26 @@ Root /gitcvs.git
 EOF
 
 test_expect_success 'req_Root (base-path)' '
-	cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
+	git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <request-base >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'req_Root failure (base-path)' '
-	! cat request-anonymous |
-	git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1
+	! git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" <request-anonymous >log 2>&1
 '
 
 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
 
 test_expect_success 'req_Root (export-all)' '
-	cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 &&
+	git-cvsserver --export-all pserver "$WORKDIR" <request-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'req_Root failure (export-all w/o directory list)' '
-	! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
+	! (git-cvsserver --export-all pserver <request-anonymous >log 2>&1 || false)'
 
 test_expect_success 'req_Root (everything together)' '
-	cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
+	git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <request-base >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh
index 2a6ee2a46787..bb236cd2b57a 100755
--- a/t/t9802-git-p4-filetype.sh
+++ b/t/t9802-git-p4-filetype.sh
@@ -175,7 +175,7 @@ test_expect_success 'keyword file create' '
 		cp k-text-k k-text-ko &&
 		p4 add -t text+ko k-text-ko &&
 
-		cat k-text-k | iconv -f ascii -t utf-16 >k-utf16-k &&
+		iconv -f ascii -t utf-16 <k-text-k >k-utf16-k &&
 		p4 add -t utf16+k k-utf16-k &&
 
 		cp k-utf16-k k-utf16-ko &&
diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh
index af4b286f9d51..6ae7ced51be1 100755
--- a/t/t9807-git-p4-submit.sh
+++ b/t/t9807-git-p4-submit.sh
@@ -418,7 +418,7 @@ test_expect_success 'description with Jobs and values on separate lines' '
 			marshal_dump job0 <change &&
 			marshal_dump job1 <change
 		) | sort >jobs &&
-		cat jobname1 jobname2 | sort >expected &&
+		sort jobname1 jobname2 >expected &&
 		test_cmp expected jobs
 	)
 '
diff --git a/t/t9824-git-p4-git-lfs.sh b/t/t9824-git-p4-git-lfs.sh
index a28dbbdd566c..fd430403d716 100755
--- a/t/t9824-git-p4-git-lfs.sh
+++ b/t/t9824-git-p4-git-lfs.sh
@@ -17,8 +17,8 @@ test_file_in_lfs () {
 	sed -n '2,2 p' "$FILE" | grep "^oid " &&
 	sed -n '3,3 p' "$FILE" | grep "^size " &&
 	test_line_count = 3 "$FILE" &&
-	cat "$FILE" | grep "size $SIZE" &&
-	HASH=$(cat "$FILE" | grep "oid sha256:" | sed -e "s/oid sha256://g") &&
+	grep "size $SIZE" "$FILE" &&
+	HASH=$(grep "oid sha256:" "$FILE" | sed -e "s/oid sha256://g") &&
 	LFS_FILE=".git/lfs/objects/$(echo "$HASH" | cut -c1-2)/$(echo "$HASH" | cut -c3-4)/$HASH" &&
 	echo $EXPECTED_CONTENT >expect &&
 	test_path_is_file "$FILE" &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 15/22] t/t1*: merge a "grep | sed" pipeline
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (13 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 14/22] t/t9*: avoid redundant uses " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t1509/prepare-chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t1509/prepare-chroot.sh b/t/t1509/prepare-chroot.sh
index 6d47e2c725f7..dc997e0a6437 100755
--- a/t/t1509/prepare-chroot.sh
+++ b/t/t1509/prepare-chroot.sh
@@ -43,7 +43,7 @@ rsync --exclude-from t/t1509/excludes -Ha . "$R$(pwd)"
 # env might slip through, see test-lib.sh, unset.*PERL_PATH
 sed 's|^PERL_PATH=.*|PERL_PATH=/bin/true|' GIT-BUILD-OPTIONS > "$R$(pwd)/GIT-BUILD-OPTIONS"
 for cmd in git $BB;do 
-	ldd $cmd | grep '/' | sed 's,.*\s\(/[^ ]*\).*,\1,' | while read i; do
+	ldd $cmd | sed -n '/\//s,.*\s\(/[^ ]*\).*,\1,p' | while read i; do
 		mkdir -p "$R$(dirname $i)"
 		cp "$i" "$R/$i"
 	done
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 16/22] t/t3*: merge a "grep | awk" pipeline
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (14 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 15/22] t/t1*: merge a "grep | sed" pipeline Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-06  0:55   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 17/22] t/t4*: merge a "grep | sed" pipeline Beat Bolli
                   ` (8 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

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
 '
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 17/22] t/t4*: merge a "grep | sed" pipeline
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (15 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 18/22] t/t5*: " Beat Bolli
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t4002-diff-basic.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index 7afc883ec374..cb3307010c1e 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -405,7 +405,7 @@ test_expect_success 'diff-tree -r B A == diff-tree -r -R A B' '
 
 test_expect_success 'diff can read from stdin' '
 	test_must_fail git diff --no-index -- MN - < NN |
-		grep -v "^index" | sed "s#/-#/NN#" >.test-a &&
+		sed "/^index/d; s#/-#/NN#" >.test-a &&
 	test_must_fail git diff --no-index -- MN NN |
 		grep -v "^index" >.test-b &&
 	test_cmp .test-a .test-b
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 18/22] t/t5*: merge a "grep | sed" pipeline
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (16 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 17/22] t/t4*: merge a "grep | sed" pipeline Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-06  0:57   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
                   ` (6 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t5401-update-hooks.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index 8b8bc47dc0b9..d8cadeec7331 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -123,7 +123,7 @@ remote: STDOUT post-update
 remote: STDERR post-update
 EOF
 test_expect_success 'send-pack stderr contains hook messages' '
-	grep ^remote: send.err | sed "s/ *\$//" >actual &&
+	sed -n "/^remote:/s/ *\$//p" send.err >actual &&
 	test_cmp expect actual
 '
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 19/22] t/t8*: merge "grep | sed" pipelines
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (17 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 18/22] t/t5*: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-06  0:59   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 20/22] t/t9*: " Beat Bolli
                   ` (5 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t8013-blame-ignore-revs.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/t/t8013-blame-ignore-revs.sh b/t/t8013-blame-ignore-revs.sh
index 9a03b0f361ff..05213d13f30f 100755
--- a/t/t8013-blame-ignore-revs.sh
+++ b/t/t8013-blame-ignore-revs.sh
@@ -25,11 +25,11 @@ test_expect_success setup '
 
 	git blame --line-porcelain file >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
 	git rev-parse X >expect &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
 	git rev-parse X >expect &&
 	test_cmp expect actual
 '
@@ -53,11 +53,11 @@ do
 	test_expect_success "ignore_rev_changing_lines ($I)" '
 		git blame --line-porcelain --ignore-rev $I file >blame_raw &&
 
-		grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+		sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
 		git rev-parse A >expect &&
 		test_cmp expect actual &&
 
-		grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+		sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
 		git rev-parse B >expect &&
 		test_cmp expect actual
 	'
@@ -79,10 +79,10 @@ test_expect_success ignore_rev_adding_unblamable_lines '
 	git rev-parse Y >expect &&
 	git blame --line-porcelain file --ignore-rev Y >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 3" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 3/s/ .*//p" blame_raw >actual &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 4" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 4/s/ .*//p" blame_raw >actual &&
 	test_cmp expect actual
 '
 
@@ -92,11 +92,11 @@ test_expect_success ignore_revs_from_files '
 	git rev-parse Y >ignore_y &&
 	git blame --line-porcelain file --ignore-revs-file ignore_x --ignore-revs-file ignore_y >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
 	git rev-parse A >expect &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
 	git rev-parse B >expect &&
 	test_cmp expect actual
 '
@@ -106,11 +106,11 @@ test_expect_success ignore_revs_from_configs_and_files '
 	git config --add blame.ignoreRevsFile ignore_x &&
 	git blame --line-porcelain file --ignore-revs-file ignore_y >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
 	git rev-parse A >expect &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
 	git rev-parse B >expect &&
 	test_cmp expect actual
 '
@@ -121,10 +121,10 @@ test_expect_success override_ignore_revs_file '
 	git blame --line-porcelain file --ignore-revs-file "" --ignore-revs-file ignore_y >blame_raw &&
 	git rev-parse X >expect &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
 	test_cmp expect actual
 	'
 test_expect_success bad_files_and_revs '
@@ -279,11 +279,11 @@ test_expect_success ignore_merge '
 	test_merge M B &&
 	git blame --line-porcelain file --ignore-rev M >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
 	git rev-parse B >expect &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 9" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -Ene "/^[0-9a-f]+ [0-9]+ 9/s/ .*//p" blame_raw >actual &&
 	git rev-parse C >expect &&
 	test_cmp expect actual
 '
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 20/22] t/t9*: merge "grep | sed" pipelines
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (18 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-06  1:00   ` Junio C Hamano
  2024-03-05 21:25 ` [PATCH 21/22] contrib/coverage-diff: avoid redundant pipelines Beat Bolli
                   ` (4 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t9118-git-svn-funky-branch-names.sh | 2 +-
 t/t9350-fast-export.sh                | 2 +-
 t/t9824-git-p4-git-lfs.sh             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh
index a159ff96b718..d3261e35b818 100755
--- a/t/t9118-git-svn-funky-branch-names.sh
+++ b/t/t9118-git-svn-funky-branch-names.sh
@@ -38,7 +38,7 @@ test_expect_success 'setup svnrepo' '
 # SVN 1.7 will truncate "not-a%40{0]" to just "not-a".
 # Look at what SVN wound up naming the branch and use that.
 # Be sure to escape the @ if it shows up.
-non_reflog=$(svn_cmd ls "$svnrepo/pr ject/branches" | grep not-a | sed 's/\///' | sed 's/@/%40/')
+non_reflog=$(svn_cmd ls "$svnrepo/pr ject/branches" | sed -ne '/not-a/ { s/\///; s/@/%40/; p }')
 
 test_expect_success 'test clone with funky branch names' '
 	git svn clone -s "$svnrepo/pr ject" project &&
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index d86d07a79d4f..1eb035ee4ce5 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -537,7 +537,7 @@ test_expect_success 'full-tree re-shows unmodified files'        '
 
 test_expect_success 'set-up a few more tags for tag export tests' '
 	git checkout -f main &&
-	HEAD_TREE=$(git show -s --pretty=raw HEAD | grep tree | sed "s/tree //") &&
+	HEAD_TREE=$(git show -s --pretty=raw HEAD | sed -n "/tree/s/tree //p") &&
 	git tag    tree_tag        -m "tagging a tree" $HEAD_TREE &&
 	git tag -a tree_tag-obj    -m "tagging a tree" $HEAD_TREE &&
 	git tag    tag-obj_tag     -m "tagging a tag" tree_tag-obj &&
diff --git a/t/t9824-git-p4-git-lfs.sh b/t/t9824-git-p4-git-lfs.sh
index fd430403d716..80c8c31e320f 100755
--- a/t/t9824-git-p4-git-lfs.sh
+++ b/t/t9824-git-p4-git-lfs.sh
@@ -18,7 +18,7 @@ test_file_in_lfs () {
 	sed -n '3,3 p' "$FILE" | grep "^size " &&
 	test_line_count = 3 "$FILE" &&
 	grep "size $SIZE" "$FILE" &&
-	HASH=$(grep "oid sha256:" "$FILE" | sed -e "s/oid sha256://g") &&
+	HASH=$(sed -ne "/oid sha256:/s/oid sha256://gp" "$FILE") &&
 	LFS_FILE=".git/lfs/objects/$(echo "$HASH" | cut -c1-2)/$(echo "$HASH" | cut -c3-4)/$HASH" &&
 	echo $EXPECTED_CONTENT >expect &&
 	test_path_is_file "$FILE" &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 21/22] contrib/coverage-diff: avoid redundant pipelines
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (19 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 20/22] t/t9*: " Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 21:25 ` [PATCH 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Merge multiple sed and "grep | awk" invocations, finally use "sort -u"
instead of "sort | uniq".

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 contrib/coverage-diff.sh | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/contrib/coverage-diff.sh b/contrib/coverage-diff.sh
index 4ec419f90048..6ce9603568ef 100755
--- a/contrib/coverage-diff.sh
+++ b/contrib/coverage-diff.sh
@@ -74,8 +74,7 @@ do
 	sort >uncovered_lines.txt
 
 	comm -12 uncovered_lines.txt new_lines.txt |
-	sed -e 's/$/\)/' |
-	sed -e 's/^/ /' >uncovered_new_lines.txt
+	sed -e 's/$/\)/' -e 's/^/ /' >uncovered_new_lines.txt
 
 	grep -q '[^[:space:]]' <uncovered_new_lines.txt &&
 	echo $file >>coverage-data.txt &&
@@ -91,11 +90,7 @@ cat coverage-data.txt
 
 echo "Commits introducing uncovered code:"
 
-commit_list=$(cat coverage-data.txt |
-	grep -E '^[0-9a-f]{7,} ' |
-	awk '{print $1;}' |
-	sort |
-	uniq)
+commit_list=$(awk '/^[0-9a-f]{7,}/ { print $1 }' coverage-data.txt | sort -u)
 
 (
 	for commit in $commit_list
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 22/22] git-quiltimport: avoid an unnecessary subshell
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (20 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 21/22] contrib/coverage-diff: avoid redundant pipelines Beat Bolli
@ 2024-03-05 21:25 ` Beat Bolli
  2024-03-05 22:55   ` Rubén Justo
  2024-03-05 22:58 ` [PATCH 00/22] avoid redundant pipelines Rubén Justo
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-05 21:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Use braces for the compound command.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 git-quiltimport.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index e3d390974331..eb34cda4092a 100755
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
@@ -148,7 +148,7 @@ do
 	if [ -z "$dry_run" ] ; then
 		git apply --index -C1 ${level:+"$level"} "$tmp_patch" &&
 		tree=$(git write-tree) &&
-		commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) &&
+		commit=$( { echo "$SUBJECT"; echo; cat "$tmp_msg"; } | git commit-tree $tree -p $commit) &&
 		git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
 	fi
 done 3<"$QUILT_SERIES"
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* Re: [PATCH 01/22] doc: avoid redundant use of cat
  2024-03-05 21:25 ` [PATCH 01/22] doc: avoid redundant use of cat Beat Bolli
@ 2024-03-05 22:24   ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-05 22:24 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> The update-hook-example.txt script uses this anti-pattern twice. Call grep
> with the input file name directy. While at it, merge the two consecutive
> grep calls.

OK.  

While at it, we could also place $allowed_users_file inside a pair
of double quotes, as the "test -f" before the part we are touching
is prepared to have $IFS whitespace in it (perhaps inside $GIT_DIR),
but I am OK to leave it as a #leftoverbit outside this topic.



> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  Documentation/howto/update-hook-example.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/howto/update-hook-example.txt b/Documentation/howto/update-hook-example.txt
> index 151ee84cebce..4e727deedd21 100644
> --- a/Documentation/howto/update-hook-example.txt
> +++ b/Documentation/howto/update-hook-example.txt
> @@ -100,7 +100,7 @@ info "The user is: '$username'"
>  
>  if test -f "$allowed_users_file"
>  then
> -  rc=$(cat $allowed_users_file | grep -v '^#' | grep -v '^$' |
> +  rc=$(grep -Ev '^(#|$)' $allowed_users_file |
>      while read heads user_patterns
>      do
>        # does this rule apply to us?
> @@ -138,7 +138,7 @@ info "'$groups'"
>  
>  if test -f "$allowed_groups_file"
>  then
> -  rc=$(cat $allowed_groups_file | grep -v '^#' | grep -v '^$' |
> +  rc=$(grep -Ev '^(#|$)' $allowed_groups_file |
>      while read heads group_patterns
>      do
>        # does this rule apply to us?

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 02/22] contrib/subtree/t: avoid redundant use of cat
  2024-03-05 21:25 ` [PATCH 02/22] contrib/subtree/t: " Beat Bolli
@ 2024-03-05 22:25   ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-05 22:25 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  contrib/subtree/t/t7900-subtree.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
> index ca4df5be8324..c3bd2a58b941 100755
> --- a/contrib/subtree/t/t7900-subtree.sh
> +++ b/contrib/subtree/t/t7900-subtree.sh
> @@ -63,7 +63,7 @@ test_create_pre2_32_repo () {
>  	git -C "$1" log -1 --format=%B HEAD^2 >msg &&
>  	test_commit -C "$1-sub" --annotate sub2 &&
>  	git clone --no-local "$1" "$1-clone" &&
> -	new_commit=$(cat msg | sed -e "s/$commit/$tag/" | git -C "$1-clone" commit-tree HEAD^2^{tree}) &&
> +	new_commit=$(sed -e "s/$commit/$tag/" msg | git -C "$1-clone" commit-tree HEAD^2^{tree}) &&
>  	git -C "$1-clone" replace HEAD^2 $new_commit
>  }

Obviously correct.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 03/22] t/lib-cvs.sh: avoid redundant use of cat
  2024-03-05 21:25 ` [PATCH 03/22] t/lib-cvs.sh: " Beat Bolli
@ 2024-03-05 22:26   ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-05 22:26 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  t/lib-cvs.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh
> index 32b347337908..57b9b2db9b3f 100644
> --- a/t/lib-cvs.sh
> +++ b/t/lib-cvs.sh
> @@ -71,8 +71,8 @@ test_cmp_branch_tree () {
>  		find . -type d -name .git -prune -o -type f -print
>  	) | sort >module-git-"$1".list &&
>  	test_cmp module-cvs-"$1".list module-git-"$1".list &&
> -	cat module-cvs-"$1".list | while read f
> +	while read f
>  	do
>  		test_cmp_branch_file "$1" "$f" || return 1
> -	done
> +	done <module-cvs-"$1".list
>  }

Again, trivially correct.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 04/22] t/annotate-tests.sh: avoid redundant use of cat
  2024-03-05 21:25 ` [PATCH 04/22] t/annotate-tests.sh: " Beat Bolli
@ 2024-03-05 22:28   ` Junio C Hamano
  2024-03-06  0:04     ` Rubén Justo
  0 siblings, 1 reply; 78+ messages in thread
From: Junio C Hamano @ 2024-03-05 22:28 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  t/annotate-tests.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
> index 5e21e84f3884..87572459e4b8 100644
> --- a/t/annotate-tests.sh
> +++ b/t/annotate-tests.sh
> @@ -532,7 +532,7 @@ test_expect_success 'blame -L :funcname with userdiff driver' '
>  		"$(cat file.template)" &&
>  	test_commit --author "B <B@test.git>" \
>  		"change" "$fortran_file" \
> -		"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
> +		"$(sed -e s/ChangeMe/IWasChanged/ file.template)" &&

Obviously correct, but 

		"$(sed -e s/ChangeMe/IWasChanged/ <file.template)" &&

might be a more faithful conversion (when "sed" looks at its ARGV[],
it did not find anything before, and it would not find anything
after this patch).

Not worth a reroll, of course, though.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 05/22] t/perf: avoid redundant use of cat
  2024-03-05 21:25 ` [PATCH 05/22] t/perf: " Beat Bolli
@ 2024-03-05 22:29   ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-05 22:29 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> Take care to redirect stdin, otherwise the output of wc would also contain
> the file name.
>
> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  t/perf/repos/inflate-repo.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/perf/repos/inflate-repo.sh b/t/perf/repos/inflate-repo.sh
> index fcfc992b5b02..412e4b450b16 100755
> --- a/t/perf/repos/inflate-repo.sh
> +++ b/t/perf/repos/inflate-repo.sh
> @@ -33,7 +33,7 @@ do
>  done
>  
>  git ls-tree -r HEAD >GEN_src_list
> -nr_src_files=$(cat GEN_src_list | wc -l)
> +nr_src_files=$(wc -l <GEN_src_list)

Good thinking to explicitly redirect into the command.

>  
>  src_branch=$(git symbolic-ref --short HEAD)

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 14/22] t/t9*: avoid redundant uses of cat
  2024-03-05 21:25 ` [PATCH 14/22] t/t9*: avoid redundant uses " Beat Bolli
@ 2024-03-05 22:52   ` Rubén Justo
  2024-03-06  0:43     ` Junio C Hamano
  0 siblings, 1 reply; 78+ messages in thread
From: Rubén Justo @ 2024-03-05 22:52 UTC (permalink / raw)
  To: Beat Bolli, git; +Cc: Junio C Hamano, Beat Bolli

On Tue, Mar 05, 2024 at 10:25:13PM +0100, Beat Bolli wrote:
> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  t/t9300-fast-import.sh          | 10 +++++-----
>  t/t9350-fast-export.sh          |  2 +-
>  t/t9400-git-cvsserver-server.sh | 35 +++++++++++++++------------------
>  t/t9802-git-p4-filetype.sh      |  2 +-
>  t/t9807-git-p4-submit.sh        |  2 +-
>  t/t9824-git-p4-git-lfs.sh       |  4 ++--
>  6 files changed, 26 insertions(+), 29 deletions(-)
> 
> diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
> index dbb5042b0b8f..c03adbdd145f 100755
> --- a/t/t9300-fast-import.sh
> +++ b/t/t9300-fast-import.sh
> @@ -986,7 +986,7 @@ test_expect_success 'L: nested tree copy does not corrupt deltas' '
>  	test_when_finished "git update-ref -d refs/heads/L2" &&
>  	git fast-import <input &&
>  	git ls-tree L2 g/b/ >tmp &&
> -	cat tmp | cut -f 2 >actual &&
> +	cut -f 2 <tmp >actual &&
>  	test_cmp expect actual &&

Nit: Maybe we can avoid tmp.

>  	git fsck $(git rev-parse L2)
>  '
> @@ -2012,7 +2012,7 @@ test_expect_success 'Q: verify first notes tree' '
>  	100644 blob $commit2
>  	100644 blob $commit3
>  	EOF
> -	cat expect.unsorted | sort >expect &&
> +	sort expect.unsorted >expect &&

Nit: I wonder if we can also avoid the cat that just precedes this hunk.

>  '
> @@ -2053,7 +2053,7 @@ test_expect_success 'Q: verify second notes tree' '
>  	100644 blob $commit2
>  	100644 blob $commit3
>  	EOF
> -	cat expect.unsorted | sort >expect &&
> +	sort expect.unsorted >expect &&

Ditto.

>  	git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
>  	test_cmp expect actual
>  '
> @@ -2091,7 +2091,7 @@ test_expect_success 'Q: verify third notes tree' '
>  	cat >expect.unsorted <<-EOF &&
>  	100644 blob $commit1
>  	EOF
> -	cat expect.unsorted | sort >expect &&
> +	sort expect.unsorted >expect &&

Ditto.

>  	git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
>  	test_cmp expect actual
>  '
> @@ -2118,7 +2118,7 @@ test_expect_success 'Q: verify fourth notes tree' '
>  	cat >expect.unsorted <<-EOF &&
>  	100644 blob $commit2
>  	EOF
> -	cat expect.unsorted | sort >expect &&
> +	sort expect.unsorted >expect &&

Ditto.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 22/22] git-quiltimport: avoid an unnecessary subshell
  2024-03-05 21:25 ` [PATCH 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
@ 2024-03-05 22:55   ` Rubén Justo
  0 siblings, 0 replies; 78+ messages in thread
From: Rubén Justo @ 2024-03-05 22:55 UTC (permalink / raw)
  To: Beat Bolli, git; +Cc: Junio C Hamano, Beat Bolli

On Tue, Mar 05, 2024 at 10:25:20PM +0100, Beat Bolli wrote:
> Merge multiple sed and "grep | awk" invocations, finally use "sort -u"
> instead of "sort | uniq".
> 
> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  contrib/coverage-diff.sh | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/contrib/coverage-diff.sh b/contrib/coverage-diff.sh
> index 4ec419f90048..6ce9603568ef 100755
> --- a/contrib/coverage-diff.sh
> +++ b/contrib/coverage-diff.sh
> @@ -74,8 +74,7 @@ do
>  	sort >uncovered_lines.txt
>  
>  	comm -12 uncovered_lines.txt new_lines.txt |
> -	sed -e 's/$/\)/' |
> -	sed -e 's/^/ /' >uncovered_new_lines.txt
> +	sed -e 's/$/\)/' -e 's/^/ /' >uncovered_new_lines.txt
>  
>  	grep -q '[^[:space:]]' <uncovered_new_lines.txt &&
>  	echo $file >>coverage-data.txt &&
> @@ -91,11 +90,7 @@ cat coverage-data.txt
>  
>  echo "Commits introducing uncovered code:"
>  
> -commit_list=$(cat coverage-data.txt |
> -	grep -E '^[0-9a-f]{7,} ' |
> -	awk '{print $1;}' |
> -	sort |
> -	uniq)
> +commit_list=$(awk '/^[0-9a-f]{7,}/ { print $1 }' coverage-data.txt | sort -u)

OK.  Not worth a re-roll of course, but perhaps some wrapping would be
welcomed here.

>  
>  (
>  	for commit in $commit_list
> -- 
> 2.44.0
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 00/22] avoid redundant pipelines
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (21 preceding siblings ...)
  2024-03-05 21:25 ` [PATCH 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
@ 2024-03-05 22:58 ` Rubén Justo
  2024-03-05 23:51 ` Junio C Hamano
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
  24 siblings, 0 replies; 78+ messages in thread
From: Rubén Justo @ 2024-03-05 22:58 UTC (permalink / raw)
  To: Beat Bolli, git
  Cc: Junio C Hamano, Beat Bolli, René Scharfe, Elijah Newren,
	Philippe Blain, Johannes Schindelin

On Tue, Mar 05, 2024 at 10:24:59PM +0100, Beat Bolli wrote:
> As follow-up to [1], here's a series that eliminates redundant
> pipelines, mostly under t/.
> 
> Spawning a process is notoriously slow on Windows, so this will improve
> test performance.
> 
> 1/22 to 14/22 remove redundant uses of "cat" where the shell handles
> input redirection from a file or the command can take a file argument.
> 
> 15/22 to 20/22 merge redundant uses of "grep" into the following "sed"
> or "awk" command. Both of these are capable of filtering themselves. I'm
> a bit on the fence about this part because readability suffers in some
> cases. It was a fun exercise, though :-)
> 
> 21/22 merges multiple "sed" calls into one and replaces a whole "cat |
> grep | awk" construct with a single "awk" call and uses "sort -u"
> instead of "sort | uniq".
> 
> 22/22 finally is a bit of an outlier in that it replaces a subshell with
> a shell compound command.

I have given it a cursory read and it looks a very good improvement.

I've left a couple of nits, none of them deserve a re-roll.

Thank you!

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 00/22] avoid redundant pipelines
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (22 preceding siblings ...)
  2024-03-05 22:58 ` [PATCH 00/22] avoid redundant pipelines Rubén Justo
@ 2024-03-05 23:51 ` Junio C Hamano
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
  24 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-05 23:51 UTC (permalink / raw)
  To: Beat Bolli
  Cc: git, Beat Bolli, René Scharfe, Elijah Newren,
	Philippe Blain, Johannes Schindelin

"Beat Bolli" <bb@drbeat.li> writes:

> As follow-up to [1], here's a series that eliminates redundant
> pipelines, mostly under t/.
>
> Spawning a process is notoriously slow on Windows, so this will improve
> test performance.

Yay!

> 1/22 to 14/22 remove redundant uses of "cat" where the shell handles
> input redirection from a file or the command can take a file argument.
>
> 15/22 to 20/22 merge redundant uses of "grep" into the following "sed"
> or "awk" command. Both of these are capable of filtering themselves. I'm
> a bit on the fence about this part because readability suffers in some
> cases. It was a fun exercise, though :-)
>
> 21/22 merges multiple "sed" calls into one and replaces a whole "cat |
> grep | awk" construct with a single "awk" call and uses "sort -u"
> instead of "sort | uniq".
>
> 22/22 finally is a bit of an outlier in that it replaces a subshell with
> a shell compound command.
>
> In the tests, I have completely arbitrarily separated the commits into
> thousands blocks to keep the commits and their reviews manageable.
>
> All tests that I was able to run still pass. I don't have p4 or cvs
> installed.
>
> [1] https://lore.kernel.org/git/20240216171046.927552-1-dev+git@drbeat.li/

Thanks.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 04/22] t/annotate-tests.sh: avoid redundant use of cat
  2024-03-05 22:28   ` Junio C Hamano
@ 2024-03-06  0:04     ` Rubén Justo
  2024-03-06  0:26       ` Junio C Hamano
  0 siblings, 1 reply; 78+ messages in thread
From: Rubén Justo @ 2024-03-06  0:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Beat Bolli

On Tue, Mar 05, 2024 at 02:28:15PM -0800, Junio C Hamano wrote:
> "Beat Bolli" <bb@drbeat.li> writes:
> 
> > Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> > ---
> >  t/annotate-tests.sh | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
> > index 5e21e84f3884..87572459e4b8 100644
> > --- a/t/annotate-tests.sh
> > +++ b/t/annotate-tests.sh
> > @@ -532,7 +532,7 @@ test_expect_success 'blame -L :funcname with userdiff driver' '
> >  		"$(cat file.template)" &&
> >  	test_commit --author "B <B@test.git>" \
> >  		"change" "$fortran_file" \
> > -		"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
> > +		"$(sed -e s/ChangeMe/IWasChanged/ file.template)" &&
> 
> Obviously correct, but 
> 
> 		"$(sed -e s/ChangeMe/IWasChanged/ <file.template)" &&
> 
> might be a more faithful conversion (when "sed" looks at its ARGV[],
> it did not find anything before, and it would not find anything
> after this patch).

Good point.  Thank you for being careful.

> 
> Not worth a reroll, of course, though.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 04/22] t/annotate-tests.sh: avoid redundant use of cat
  2024-03-06  0:04     ` Rubén Justo
@ 2024-03-06  0:26       ` Junio C Hamano
  2024-03-06  0:38         ` Rubén Justo
  0 siblings, 1 reply; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06  0:26 UTC (permalink / raw)
  To: Rubén Justo; +Cc: git, Beat Bolli

Rubén Justo <rjusto@gmail.com> writes:

> On Tue, Mar 05, 2024 at 02:28:15PM -0800, Junio C Hamano wrote:
>> "Beat Bolli" <bb@drbeat.li> writes:
>> 
>> > Signed-off-by: Beat Bolli <dev+git@drbeat.li>
>> > ---
>> >  t/annotate-tests.sh | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
>> > index 5e21e84f3884..87572459e4b8 100644
>> > --- a/t/annotate-tests.sh
>> > +++ b/t/annotate-tests.sh
>> > @@ -532,7 +532,7 @@ test_expect_success 'blame -L :funcname with userdiff driver' '
>> >  		"$(cat file.template)" &&
>> >  	test_commit --author "B <B@test.git>" \
>> >  		"change" "$fortran_file" \
>> > -		"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
>> > +		"$(sed -e s/ChangeMe/IWasChanged/ file.template)" &&
>> 
>> Obviously correct, but 
>> 
>> 		"$(sed -e s/ChangeMe/IWasChanged/ <file.template)" &&
>> 
>> might be a more faithful conversion (when "sed" looks at its ARGV[],
>> it did not find anything before, and it would not find anything
>> after this patch).
>
> Good point.  Thank you for being careful.

Heh, I actually consider it the most irrelevant one among my
comments.  I actally do not think there is a way tell if your "sed"
invocation is reading from one of the files listed on the command
line, or reading from the standard input, from your sed script,
unlike say Perl that has access to @ARGV.  Certainly a simple s/A/B/
would not care.

Compared to that, rewriting $(cat file | wc -l) to $(wc -l <file)
does matter, which was done in [05/22].

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 04/22] t/annotate-tests.sh: avoid redundant use of cat
  2024-03-06  0:26       ` Junio C Hamano
@ 2024-03-06  0:38         ` Rubén Justo
  0 siblings, 0 replies; 78+ messages in thread
From: Rubén Justo @ 2024-03-06  0:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Beat Bolli

On Tue, Mar 05, 2024 at 04:26:27PM -0800, Junio C Hamano wrote:
> Rubén Justo <rjusto@gmail.com> writes:
> 
> > On Tue, Mar 05, 2024 at 02:28:15PM -0800, Junio C Hamano wrote:
> >> "Beat Bolli" <bb@drbeat.li> writes:
> >> 
> >> > Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> >> > ---
> >> >  t/annotate-tests.sh | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
> >> > index 5e21e84f3884..87572459e4b8 100644
> >> > --- a/t/annotate-tests.sh
> >> > +++ b/t/annotate-tests.sh
> >> > @@ -532,7 +532,7 @@ test_expect_success 'blame -L :funcname with userdiff driver' '
> >> >  		"$(cat file.template)" &&
> >> >  	test_commit --author "B <B@test.git>" \
> >> >  		"change" "$fortran_file" \
> >> > -		"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
> >> > +		"$(sed -e s/ChangeMe/IWasChanged/ file.template)" &&
> >> 
> >> Obviously correct, but 
> >> 
> >> 		"$(sed -e s/ChangeMe/IWasChanged/ <file.template)" &&
> >> 
> >> might be a more faithful conversion (when "sed" looks at its ARGV[],
> >> it did not find anything before, and it would not find anything
> >> after this patch).
> >
> > Good point.  Thank you for being careful.
> 
> Heh, I actually consider it the most irrelevant one among my
> comments.  I actally do not think there is a way tell if your "sed"
> invocation is reading from one of the files listed on the command
> line, or reading from the standard input, from your sed script,
> unlike say Perl that has access to @ARGV.  Certainly a simple s/A/B/
> would not care.
> 
> Compared to that, rewriting $(cat file | wc -l) to $(wc -l <file)
> does matter, which was done in [05/22].

Yeah, that is needed; faithfulness is appreciated.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 14/22] t/t9*: avoid redundant uses of cat
  2024-03-05 22:52   ` Rubén Justo
@ 2024-03-06  0:43     ` Junio C Hamano
  2024-03-06  1:10       ` Rubén Justo
  0 siblings, 1 reply; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06  0:43 UTC (permalink / raw)
  To: Rubén Justo; +Cc: Beat Bolli, git, Beat Bolli

Rubén Justo <rjusto@gmail.com> writes:

>>  	test_when_finished "git update-ref -d refs/heads/L2" &&
>>  	git fast-import <input &&
>>  	git ls-tree L2 g/b/ >tmp &&
>> -	cat tmp | cut -f 2 >actual &&
>> +	cut -f 2 <tmp >actual &&
>>  	test_cmp expect actual &&
>
> Nit: Maybe we can avoid tmp.

Piping "git ls-tree" output to "cut" would hide the exit status of
"git ls-tree" if it fails, which is not a good idea, so I do not
think of a way to avoid tmp so easily.

>
>>  	git fsck $(git rev-parse L2)
>>  '
>> @@ -2012,7 +2012,7 @@ test_expect_success 'Q: verify first notes tree' '
>>  	100644 blob $commit2
>>  	100644 blob $commit3
>>  	EOF
>> -	cat expect.unsorted | sort >expect &&
>> +	sort expect.unsorted >expect &&
>
> Nit: I wonder if we can also avoid the cat that just precedes this hunk.

The whole thing reads like this:

test_expect_success 'Q: verify first notes tree' '
	cat >expect.unsorted <<-EOF &&
	100644 blob $commit1
	100644 blob $commit2
	100644 blob $commit3
	EOF
	cat expect.unsorted | sort >expect &&
	git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
	test_cmp expect actual
'

As we are not in the business of debugging system-provided "sort",
I agree that

	sort >expect <<-EOF &&
	100644 blob $commit1
	100644 blob $commit2
	100644 blob $commit3
	EOF

without having to use expect.unsorted would probably make sense.
Well spotted.

This is outside the topic, but this test has different clean-up
opportunities that are not related to the "do not run cat a single
file and send its output into a pipe" pattern.  The expected output
we see here implicitly depends on the fact that the notes tree is so
small that it hasn't been reorganized using fan-out levels.  If the
algorithm to decide when to start using fan-out directories changes,
this test can break.  To avoid that, we may need to do something
like

	git ls-tree -r refs/notes/foobar~2 >ls-tree &&
	sed -e "s/ [0-9a-f]*               / /" -e "s|/||g" >actual &&

so that we will get the commit object name without the slashes that
show the fan-out directories.  Also, the current "actual" generation
hides the exit status from "git cat-file".

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 09/22] t/t4*: avoid redundant uses of cat
  2024-03-05 21:25 ` [PATCH 09/22] t/t4*: " Beat Bolli
@ 2024-03-06  0:49   ` Junio C Hamano
  2024-03-06  1:08   ` Eric Sunshine
  1 sibling, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06  0:49 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> @@ -786,7 +786,7 @@ test_expect_success 'am takes patches from a Pine mailbox' '
>  	rm -fr .git/rebase-apply &&
>  	git reset --hard &&
>  	git checkout first &&
> -	cat pine patch1 | git am &&
> +	git am pine patch1 &&
>  	test_path_is_missing .git/rebase-apply &&
>  	git diff --exit-code main^..HEAD
>  '

I am not so certain about this one.

We can say "sed can read from the file listed on the command line,
or it can read from its standard input, so we can use whichever is
convenient for us", as we are not in the business of testing "sed"
that is supplied by the system.

On the other hand, the ability of "git am" to read either from the
files listed on the command line or from the standard input is not a
given.  It is one of the many aspects of how "git am" behaves that
we are testing.  By changing a test that feeds the contents of the
mailboxes from the standard input to instead have the command read
these mailbox files listed on the command line, this changes what
gets tested.

All other changes in the file look good to me.

Thanks.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 16/22] t/t3*: merge a "grep | awk" pipeline
  2024-03-05 21:25 ` [PATCH 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
@ 2024-03-06  0:55   ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06  0:55 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"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.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 18/22] t/t5*: merge a "grep | sed" pipeline
  2024-03-05 21:25 ` [PATCH 18/22] t/t5*: " Beat Bolli
@ 2024-03-06  0:57   ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06  0:57 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  t/t5401-update-hooks.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
> index 8b8bc47dc0b9..d8cadeec7331 100755
> --- a/t/t5401-update-hooks.sh
> +++ b/t/t5401-update-hooks.sh
> @@ -123,7 +123,7 @@ remote: STDOUT post-update
>  remote: STDERR post-update
>  EOF
>  test_expect_success 'send-pack stderr contains hook messages' '
> -	grep ^remote: send.err | sed "s/ *\$//" >actual &&
> +	sed -n "/^remote:/s/ *\$//p" send.err >actual &&
>  	test_cmp expect actual
>  '

Both 17 & 18 look good.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 19/22] t/t8*: merge "grep | sed" pipelines
  2024-03-05 21:25 ` [PATCH 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
@ 2024-03-06  0:59   ` Junio C Hamano
  2024-03-06  2:17     ` Todd Zullinger
  0 siblings, 1 reply; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06  0:59 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  t/t8013-blame-ignore-revs.sh | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/t/t8013-blame-ignore-revs.sh b/t/t8013-blame-ignore-revs.sh
> index 9a03b0f361ff..05213d13f30f 100755
> --- a/t/t8013-blame-ignore-revs.sh
> +++ b/t/t8013-blame-ignore-revs.sh
> @@ -25,11 +25,11 @@ test_expect_success setup '
>  
>  	git blame --line-porcelain file >blame_raw &&
>  
> -	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
> +	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&

Isn't -E a GNUism?

At least,

    https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html

does not seem to have it (we may need to fix t6030 to rid its only
existing use).

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 20/22] t/t9*: merge "grep | sed" pipelines
  2024-03-05 21:25 ` [PATCH 20/22] t/t9*: " Beat Bolli
@ 2024-03-06  1:00   ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06  1:00 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Beat Bolli

"Beat Bolli" <bb@drbeat.li> writes:

> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  t/t9118-git-svn-funky-branch-names.sh | 2 +-
>  t/t9350-fast-export.sh                | 2 +-
>  t/t9824-git-p4-git-lfs.sh             | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

Looking good.  Thanks.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 09/22] t/t4*: avoid redundant uses of cat
  2024-03-05 21:25 ` [PATCH 09/22] t/t4*: " Beat Bolli
  2024-03-06  0:49   ` Junio C Hamano
@ 2024-03-06  1:08   ` Eric Sunshine
  2024-03-06 20:58     ` Beat Bolli
  1 sibling, 1 reply; 78+ messages in thread
From: Eric Sunshine @ 2024-03-06  1:08 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Junio C Hamano, Beat Bolli

On Tue, Mar 5, 2024 at 4:31 PM Beat Bolli <bb@drbeat.li> wrote:
> diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
> @@ -232,7 +232,7 @@ keep_only_cr () {
>  test_expect_success 'external diff with autocrlf = true' '
>         test_config core.autocrlf true &&
>         GIT_EXTERNAL_DIFF=./fake-diff.sh git diff &&
> -       test $(wc -l < crlfed.txt) = $(cat crlfed.txt | keep_only_cr | wc -c)
> +       test $(wc -l < crlfed.txt) = $(keep_only_cr <crlfed.txt | wc -c)
>  '

Could also fix the style problem (drop whitespace after existing `<`
operator) while here, but not at all worth a reroll.

> diff --git a/t/t4150-am.sh b/t/t4150-am.sh
> @@ -786,7 +786,7 @@ test_expect_success 'am takes patches from a Pine mailbox' '
>         git checkout first &&
> -       cat pine patch1 | git am &&
> +       git am pine patch1 &&

As with Junio, the semantic change made here concerned me.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 14/22] t/t9*: avoid redundant uses of cat
  2024-03-06  0:43     ` Junio C Hamano
@ 2024-03-06  1:10       ` Rubén Justo
  0 siblings, 0 replies; 78+ messages in thread
From: Rubén Justo @ 2024-03-06  1:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Beat Bolli, git, Beat Bolli

On Tue, Mar 05, 2024 at 04:43:33PM -0800, Junio C Hamano wrote:
> Rubén Justo <rjusto@gmail.com> writes:
> 
> >>  	git ls-tree L2 g/b/ >tmp &&
> >> -	cat tmp | cut -f 2 >actual &&
> >> +	cut -f 2 <tmp >actual &&
> >>  	test_cmp expect actual &&
> >
> > Nit: Maybe we can avoid tmp.
> 
> Piping "git ls-tree" output to "cut" would hide the exit status of
> "git ls-tree" if it fails, which is not a good idea, so I do not
> think of a way to avoid tmp so easily.

Right.  Thanks for pointing that out.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 19/22] t/t8*: merge "grep | sed" pipelines
  2024-03-06  0:59   ` Junio C Hamano
@ 2024-03-06  2:17     ` Todd Zullinger
  2024-03-06 16:03       ` Junio C Hamano
  2024-03-06 21:03       ` Beat Bolli
  0 siblings, 2 replies; 78+ messages in thread
From: Todd Zullinger @ 2024-03-06  2:17 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Beat Bolli, git, Beat Bolli

Junio C Hamano wrote:
> Isn't -E a GNUism?
>
> At least,
> 
>     https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
> 
> does not seem to have it (we may need to fix t6030 to rid its only
> existing use).

I _thought_ that -r was the GNUism.  The GNU sed-4.8 manpage
says:

    -E, -r, --regexp-extended
        use extended regular expressions in the script
        (for portability use POSIX -E).

That doesn't mean the man page is right, of course. :)

https://www.austingroupbugs.net/view.php?id=528 suggests
that -E has been adopted and, importanly, is more widely
supported than -r (if we were considering using that rather
than rewriting this to not use ERE syntax).  MacOS in
particular supports -E but not -r, according to that link.

It seems like the documentation hasn't quite caught up to
reality yet, perhaps?

-- 
Todd

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 19/22] t/t8*: merge "grep | sed" pipelines
  2024-03-06  2:17     ` Todd Zullinger
@ 2024-03-06 16:03       ` Junio C Hamano
  2024-03-06 21:03       ` Beat Bolli
  1 sibling, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06 16:03 UTC (permalink / raw)
  To: Todd Zullinger; +Cc: Beat Bolli, git, Beat Bolli

Todd Zullinger <tmz@pobox.com> writes:

> Junio C Hamano wrote:
>> Isn't -E a GNUism?
> ...
> https://www.austingroupbugs.net/view.php?id=528 suggests
> that -E has been adopted 

Then that is OK.  Thanks for a good news.

> and, importanly, is more widely
> supported than -r (if we were considering using that rather
> than rewriting this to not use ERE syntax).

At least I wasn't, so it is irrelevant to this review, but it still
is nice to know about it [*].  Thanks.

[Footnote] 

 * or is the knowledge of '-r' itself also irrelevant, now '-E' is
   kosher and widely usable?

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 09/22] t/t4*: avoid redundant uses of cat
  2024-03-06  1:08   ` Eric Sunshine
@ 2024-03-06 20:58     ` Beat Bolli
  0 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-06 20:58 UTC (permalink / raw)
  To: Eric Sunshine, Beat Bolli; +Cc: git, Junio C Hamano

On 06.03.24 02:08, Eric Sunshine wrote:
> On Tue, Mar 5, 2024 at 4:31 PM Beat Bolli <bb@drbeat.li> wrote:
>> diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
>> @@ -232,7 +232,7 @@ keep_only_cr () {
>>   test_expect_success 'external diff with autocrlf = true' '
>>          test_config core.autocrlf true &&
>>          GIT_EXTERNAL_DIFF=./fake-diff.sh git diff &&
>> -       test $(wc -l < crlfed.txt) = $(cat crlfed.txt | keep_only_cr | wc -c)
>> +       test $(wc -l < crlfed.txt) = $(keep_only_cr <crlfed.txt | wc -c)
>>   '
> 
> Could also fix the style problem (drop whitespace after existing `<`
> operator) while here, but not at all worth a reroll.
> 
>> diff --git a/t/t4150-am.sh b/t/t4150-am.sh
>> @@ -786,7 +786,7 @@ test_expect_success 'am takes patches from a Pine mailbox' '
>>          git checkout first &&
>> -       cat pine patch1 | git am &&
>> +       git am pine patch1 &&
> 
> As with Junio, the semantic change made here concerned me.

I was even more on the fence about this hunk than the others, but then 
the test was about 'am takes patches from a Pine mailbox', not 
specifically about reading a Pine mailbox from stdin. But I can drop 
this hunk in v2.

Cheers, Beat

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 19/22] t/t8*: merge "grep | sed" pipelines
  2024-03-06  2:17     ` Todd Zullinger
  2024-03-06 16:03       ` Junio C Hamano
@ 2024-03-06 21:03       ` Beat Bolli
  2024-03-06 21:47         ` Junio C Hamano
  1 sibling, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-06 21:03 UTC (permalink / raw)
  To: Todd Zullinger, Junio C Hamano; +Cc: Beat Bolli, git

On 06.03.24 03:17, Todd Zullinger wrote:
> Junio C Hamano wrote:
>> Isn't -E a GNUism?
>>
>> At least,
>>
>>      https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
>>
>> does not seem to have it (we may need to fix t6030 to rid its only
>> existing use).
> 
> I _thought_ that -r was the GNUism.  The GNU sed-4.8 manpage
> says:
> 
>      -E, -r, --regexp-extended
>          use extended regular expressions in the script
>          (for portability use POSIX -E).
> 
> That doesn't mean the man page is right, of course. :)
> 
> https://www.austingroupbugs.net/view.php?id=528 suggests
> that -E has been adopted and, importanly, is more widely
> supported than -r (if we were considering using that rather
> than rewriting this to not use ERE syntax).  MacOS in
> particular supports -E but not -r, according to that link.
> 
> It seems like the documentation hasn't quite caught up to
> reality yet, perhaps?
> 

At least macOS Ventura and later supports "sed -E". I can't say what the 
more exotic platforms (NonStop?) have.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 19/22] t/t8*: merge "grep | sed" pipelines
  2024-03-06 21:03       ` Beat Bolli
@ 2024-03-06 21:47         ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-06 21:47 UTC (permalink / raw)
  To: Beat Bolli; +Cc: Todd Zullinger, Beat Bolli, git

Beat Bolli <dev+git@drbeat.li> writes:

> On 06.03.24 03:17, Todd Zullinger wrote:
>> Junio C Hamano wrote:
>>> Isn't -E a GNUism?
>>>
>>> At least,
>>>
>>>      https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
>>>
>>> does not seem to have it (we may need to fix t6030 to rid its only
>>> existing use).
>> I _thought_ that -r was the GNUism.  The GNU sed-4.8 manpage
>> says:
>>      -E, -r, --regexp-extended
>>          use extended regular expressions in the script
>>          (for portability use POSIX -E).
>> That doesn't mean the man page is right, of course. :)
>> https://www.austingroupbugs.net/view.php?id=528 suggests
>> that -E has been adopted and, importanly, is more widely
> ...
> At least macOS Ventura and later supports "sed -E". I can't say what
> the more exotic platforms (NonStop?) have.

More exotic platforms may lag behind, and it is a very valid
concern.  Also, the bug #528 does talk about -E being accepted, but
wasn't it accepted for Issue 8, which is not finalized yet, no?

So it seems it may be prudent to stick to BRE if we were to squash
these pipelines into a single sed invocation, at least for a few
years.

Thanks.

^ permalink raw reply	[flat|nested] 78+ messages in thread

* [PATCH v2 00/22] avoid redundant pipelines
  2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
                   ` (23 preceding siblings ...)
  2024-03-05 23:51 ` Junio C Hamano
@ 2024-03-15 19:45 ` Beat Bolli
  2024-03-15 19:45   ` [PATCH v2 01/22] doc: avoid redundant use of cat Beat Bolli
                     ` (22 more replies)
  24 siblings, 23 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:45 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Beat Bolli, René Scharfe, Elijah Newren,
	Philippe Blain, Johannes Schindelin

As follow-up to [1], here's a series that eliminates redundant
pipelines, mostly under t/.

Spawning a process is notoriously slow on Windows, so this will improve
test performance.

1/22 to 14/22 remove redundant uses of "cat" where the shell handles
input redirection from a file or the command can take a file argument.

15/22 to 20/22 merge redundant uses of "grep" into the following "sed"
or "awk" command. Both of these are capable of filtering themselves.

21/22 merges multiple "sed" calls into one and replaces a whole "cat |
grep | awk" construct with a single "awk" call and uses "sort -u"
instead of "sort | uniq".

22/22 finally is a bit of an outlier in that it replaces a subshell with
a shell compound command.

In the tests, I have completely arbitrarily separated the commits into
thousands blocks to keep the commits and their reviews manageable.

All tests that I was able to run still pass. I don't have p4 or cvs
installed.

[1] https://lore.kernel.org/git/20240216171046.927552-1-dev+git@drbeat.li/


Changes from v1 (see also the range-diff below):

- 09/22: leave a "cat" that concatenates two files as input to "git am"

- 14/22: replace all instances of

      cat >expect.unsorted <<... && sort expect.unsorted >expect

  with

      "sort >expect <<..."

- 19/22: avoid "sed -E" (use extended regex syntax) which may not be
  supported on each platform with equivalent basic regexes

Beat Bolli (22):
  doc: avoid redundant use of cat
  contrib/subtree/t: avoid redundant use of cat
  t/lib-cvs.sh: avoid redundant use of cat
  t/annotate-tests.sh: avoid redundant use of cat
  t/perf: avoid redundant use of cat
  t/t0*: avoid redundant uses of cat
  t/t1*: avoid redundant uses of cat
  t/t3*: avoid redundant uses of cat
  t/t4*: avoid redundant uses of cat
  t/t5*: avoid redundant uses of cat
  t/t6*: avoid redundant uses of cat
  t/t7*: avoid redundant use of cat
  t/t8*: avoid redundant use of cat
  t/t9*: avoid redundant uses of cat
  t/t1*: merge a "grep | sed" pipeline
  t/t3*: merge a "grep | awk" pipeline
  t/t4*: merge a "grep | sed" pipeline
  t/t5*: merge a "grep | sed" pipeline
  t/t8*: merge "grep | sed" pipelines
  t/t9*: merge "grep | sed" pipelines
  contrib/coverage-diff: avoid redundant pipelines
  git-quiltimport: avoid an unnecessary subshell

 Documentation/howto/update-hook-example.txt |  4 +--
 contrib/coverage-diff.sh                    |  9 ++----
 contrib/subtree/t/t7900-subtree.sh          |  2 +-
 git-quiltimport.sh                          |  2 +-
 t/annotate-tests.sh                         |  2 +-
 t/lib-cvs.sh                                |  4 +--
 t/perf/repos/inflate-repo.sh                |  2 +-
 t/t0002-gitfile.sh                          |  2 +-
 t/t0011-hashmap.sh                          |  2 +-
 t/t0028-working-tree-encoding.sh            |  4 +--
 t/t0204-gettext-reencode-sanity.sh          |  2 +-
 t/t1007-hash-object.sh                      |  6 ++--
 t/t1091-sparse-checkout-builtin.sh          |  2 +-
 t/t1509/prepare-chroot.sh                   |  2 +-
 t/t3200-branch.sh                           |  2 +-
 t/t3321-notes-stripspace.sh                 |  8 ++---
 t/t3920-crlf-messages.sh                    |  4 +--
 t/t4002-diff-basic.sh                       |  2 +-
 t/t4020-diff-external.sh                    |  2 +-
 t/t4205-log-pretty-formats.sh               |  2 +-
 t/t4301-merge-tree-write-tree.sh            |  8 ++---
 t/t5100-mailinfo.sh                         |  2 +-
 t/t5317-pack-objects-filter-objects.sh      |  2 +-
 t/t5401-update-hooks.sh                     |  2 +-
 t/t5534-push-signed.sh                      |  2 +-
 t/t6112-rev-list-filters-objects.sh         |  2 +-
 t/t6413-merge-crlf.sh                       |  4 +--
 t/t7704-repack-cruft.sh                     |  2 +-
 t/t8010-cat-file-filters.sh                 |  2 +-
 t/t8013-blame-ignore-revs.sh                | 28 ++++++++---------
 t/t9118-git-svn-funky-branch-names.sh       |  2 +-
 t/t9300-fast-import.sh                      | 14 +++------
 t/t9350-fast-export.sh                      |  4 +--
 t/t9400-git-cvsserver-server.sh             | 35 ++++++++++-----------
 t/t9802-git-p4-filetype.sh                  |  2 +-
 t/t9807-git-p4-submit.sh                    |  2 +-
 t/t9824-git-p4-git-lfs.sh                   |  4 +--
 37 files changed, 85 insertions(+), 97 deletions(-)

Range-diff from v1:

 1:  270f19b35e36 =  1:  270f19b35e36 doc: avoid redundant use of cat
 2:  eed1fc58a7e4 =  2:  eed1fc58a7e4 contrib/subtree/t: avoid redundant use of cat
 3:  c131707668ac =  3:  c131707668ac t/lib-cvs.sh: avoid redundant use of cat
 4:  da69f859de63 =  4:  da69f859de63 t/annotate-tests.sh: avoid redundant use of cat
 5:  07b3bf33577f =  5:  07b3bf33577f t/perf: avoid redundant use of cat
 6:  38907650b33e =  6:  38907650b33e t/t0*: avoid redundant uses of cat
 7:  b8b8b7ae47a6 =  7:  b8b8b7ae47a6 t/t1*: avoid redundant uses of cat
 8:  7c91c4092e7d =  8:  7c91c4092e7d t/t3*: avoid redundant uses of cat
 9:  3c9df39774d8 !  9:  1a80eaa97169 t/t4*: avoid redundant uses of cat
    @@ t/t4020-diff-external.sh: keep_only_cr () {
      
      test_expect_success 'diff --cached' '
     
    - ## t/t4150-am.sh ##
    -@@ t/t4150-am.sh: test_expect_success 'am takes patches from a Pine mailbox' '
    - 	rm -fr .git/rebase-apply &&
    - 	git reset --hard &&
    - 	git checkout first &&
    --	cat pine patch1 | git am &&
    -+	git am pine patch1 &&
    - 	test_path_is_missing .git/rebase-apply &&
    - 	git diff --exit-code main^..HEAD
    - '
    -
      ## t/t4205-log-pretty-formats.sh ##
     @@ t/t4205-log-pretty-formats.sh: test_expect_success 'NUL termination with --reflog --pretty=oneline' '
      	for r in $revs
10:  a3207b26a80e = 10:  3ac01bbcaafa t/t5*: avoid redundant uses of cat
11:  bde50bfd2552 = 11:  a4a6aaf4654b t/t6*: avoid redundant uses of cat
12:  84978c31631f = 12:  4b7b9df129a3 t/t7*: avoid redundant use of cat
13:  a555a1809e84 = 13:  ebf1e5eeadbd t/t8*: avoid redundant use of cat
14:  667c04d6c665 ! 14:  34cf66aeff80 t/t9*: avoid redundant uses of cat
    @@ t/t9300-fast-import.sh: test_expect_success 'L: nested tree copy does not corrup
      	test_cmp expect actual &&
      	git fsck $(git rev-parse L2)
      '
    -@@ t/t9300-fast-import.sh: test_expect_success 'Q: verify first notes tree' '
    +@@ t/t9300-fast-import.sh: test_expect_success 'Q: verify first notes commit' '
    + '
    + 
    + test_expect_success 'Q: verify first notes tree' '
    +-	cat >expect.unsorted <<-EOF &&
    ++	sort >expect <<-EOF &&
    + 	100644 blob $commit1
      	100644 blob $commit2
      	100644 blob $commit3
      	EOF
     -	cat expect.unsorted | sort >expect &&
    -+	sort expect.unsorted >expect &&
      	git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
      	test_cmp expect actual
      '
    -@@ t/t9300-fast-import.sh: test_expect_success 'Q: verify second notes tree' '
    +@@ t/t9300-fast-import.sh: test_expect_success 'Q: verify second notes commit' '
    + '
    + 
    + test_expect_success 'Q: verify second notes tree' '
    +-	cat >expect.unsorted <<-EOF &&
    ++	sort >expect <<-EOF &&
    + 	100644 blob $commit1
      	100644 blob $commit2
      	100644 blob $commit3
      	EOF
     -	cat expect.unsorted | sort >expect &&
    -+	sort expect.unsorted >expect &&
      	git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
      	test_cmp expect actual
      '
    -@@ t/t9300-fast-import.sh: test_expect_success 'Q: verify third notes tree' '
    - 	cat >expect.unsorted <<-EOF &&
    +@@ t/t9300-fast-import.sh: test_expect_success 'Q: verify third notes commit' '
    + '
    + 
    + test_expect_success 'Q: verify third notes tree' '
    +-	cat >expect.unsorted <<-EOF &&
    ++	sort >expect <<-EOF &&
      	100644 blob $commit1
      	EOF
     -	cat expect.unsorted | sort >expect &&
    -+	sort expect.unsorted >expect &&
      	git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
      	test_cmp expect actual
      '
    -@@ t/t9300-fast-import.sh: test_expect_success 'Q: verify fourth notes tree' '
    - 	cat >expect.unsorted <<-EOF &&
    +@@ t/t9300-fast-import.sh: test_expect_success 'Q: verify fourth notes commit' '
    + '
    + 
    + test_expect_success 'Q: verify fourth notes tree' '
    +-	cat >expect.unsorted <<-EOF &&
    ++	sort >expect <<-EOF &&
      	100644 blob $commit2
      	EOF
     -	cat expect.unsorted | sort >expect &&
    -+	sort expect.unsorted >expect &&
      	git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
      	test_cmp expect actual
      '
15:  6dd79d30c42a = 15:  be300cb0a65a t/t1*: merge a "grep | sed" pipeline
16:  db61133fa92f = 16:  d6f5e21942ff t/t3*: merge a "grep | awk" pipeline
17:  5ce7ddeb2fbd = 17:  68a5f3f743d0 t/t4*: merge a "grep | sed" pipeline
18:  6ed68fe96493 = 18:  3a7e2a8fc388 t/t5*: merge a "grep | sed" pipeline
19:  698a5524b5c4 ! 19:  e6ec4b3a0451 t/t8*: merge "grep | sed" pipelines
    @@ t/t8013-blame-ignore-revs.sh: test_expect_success setup '
      	git blame --line-porcelain file >blame_raw &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
      	git rev-parse X >expect &&
      	test_cmp expect actual &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
      	git rev-parse X >expect &&
      	test_cmp expect actual
      '
    @@ t/t8013-blame-ignore-revs.sh: do
      		git blame --line-porcelain --ignore-rev $I file >blame_raw &&
      
     -		grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
    -+		sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
    ++		sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
      		git rev-parse A >expect &&
      		test_cmp expect actual &&
      
     -		grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
    -+		sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
    ++		sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
      		git rev-parse B >expect &&
      		test_cmp expect actual
      	'
    @@ t/t8013-blame-ignore-revs.sh: test_expect_success ignore_rev_adding_unblamable_l
      	git blame --line-porcelain file --ignore-rev Y >blame_raw &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 3" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 3/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 3/s/ .*//p" blame_raw >actual &&
      	test_cmp expect actual &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 4" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 4/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 4/s/ .*//p" blame_raw >actual &&
      	test_cmp expect actual
      '
      
    @@ t/t8013-blame-ignore-revs.sh: test_expect_success ignore_revs_from_files '
      	git blame --line-porcelain file --ignore-revs-file ignore_x --ignore-revs-file ignore_y >blame_raw &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
      	git rev-parse A >expect &&
      	test_cmp expect actual &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
      	git rev-parse B >expect &&
      	test_cmp expect actual
      '
    @@ t/t8013-blame-ignore-revs.sh: test_expect_success ignore_revs_from_configs_and_f
      	git blame --line-porcelain file --ignore-revs-file ignore_y >blame_raw &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
      	git rev-parse A >expect &&
      	test_cmp expect actual &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
      	git rev-parse B >expect &&
      	test_cmp expect actual
      '
    @@ t/t8013-blame-ignore-revs.sh: test_expect_success override_ignore_revs_file '
      	git rev-parse X >expect &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
      	test_cmp expect actual &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 2/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
      	test_cmp expect actual
      	'
      test_expect_success bad_files_and_revs '
    @@ t/t8013-blame-ignore-revs.sh: test_expect_success ignore_merge '
      	git blame --line-porcelain file --ignore-rev M >blame_raw &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 1/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
      	git rev-parse B >expect &&
      	test_cmp expect actual &&
      
     -	grep -E "^[0-9a-f]+ [0-9]+ 9" blame_raw | sed -e "s/ .*//" >actual &&
    -+	sed -Ene "/^[0-9a-f]+ [0-9]+ 9/s/ .*//p" blame_raw >actual &&
    ++	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 9/s/ .*//p" blame_raw >actual &&
      	git rev-parse C >expect &&
      	test_cmp expect actual
      '
20:  6b3345667040 = 20:  4772acb80163 t/t9*: merge "grep | sed" pipelines
21:  1784d5f3fdc1 = 21:  a34653f91589 contrib/coverage-diff: avoid redundant pipelines
22:  4858de8ce44f = 22:  6c62dee0daa1 git-quiltimport: avoid an unnecessary subshell
-- 
2.44.0

From: Beat Bolli <dev+git@drbeat.li>

*** BLURB HERE ***

Beat Bolli (22):
  doc: avoid redundant use of cat
  contrib/subtree/t: avoid redundant use of cat
  t/lib-cvs.sh: avoid redundant use of cat
  t/annotate-tests.sh: avoid redundant use of cat
  t/perf: avoid redundant use of cat
  t/t0*: avoid redundant uses of cat
  t/t1*: avoid redundant uses of cat
  t/t3*: avoid redundant uses of cat
  t/t4*: avoid redundant uses of cat
  t/t5*: avoid redundant uses of cat
  t/t6*: avoid redundant uses of cat
  t/t7*: avoid redundant use of cat
  t/t8*: avoid redundant use of cat
  t/t9*: avoid redundant uses of cat
  t/t1*: merge a "grep | sed" pipeline
  t/t3*: merge a "grep | awk" pipeline
  t/t4*: merge a "grep | sed" pipeline
  t/t5*: merge a "grep | sed" pipeline
  t/t8*: merge "grep | sed" pipelines
  t/t9*: merge "grep | sed" pipelines
  contrib/coverage-diff: avoid redundant pipelines
  git-quiltimport: avoid an unnecessary subshell

 Documentation/howto/update-hook-example.txt |  4 +--
 contrib/coverage-diff.sh                    |  9 ++----
 contrib/subtree/t/t7900-subtree.sh          |  2 +-
 git-quiltimport.sh                          |  2 +-
 t/annotate-tests.sh                         |  2 +-
 t/lib-cvs.sh                                |  4 +--
 t/perf/repos/inflate-repo.sh                |  2 +-
 t/t0002-gitfile.sh                          |  2 +-
 t/t0011-hashmap.sh                          |  2 +-
 t/t0028-working-tree-encoding.sh            |  4 +--
 t/t0204-gettext-reencode-sanity.sh          |  2 +-
 t/t1007-hash-object.sh                      |  6 ++--
 t/t1091-sparse-checkout-builtin.sh          |  2 +-
 t/t1509/prepare-chroot.sh                   |  2 +-
 t/t3200-branch.sh                           |  2 +-
 t/t3321-notes-stripspace.sh                 |  8 ++---
 t/t3920-crlf-messages.sh                    |  4 +--
 t/t4002-diff-basic.sh                       |  2 +-
 t/t4020-diff-external.sh                    |  2 +-
 t/t4205-log-pretty-formats.sh               |  2 +-
 t/t4301-merge-tree-write-tree.sh            |  8 ++---
 t/t5100-mailinfo.sh                         |  2 +-
 t/t5317-pack-objects-filter-objects.sh      |  2 +-
 t/t5401-update-hooks.sh                     |  2 +-
 t/t5534-push-signed.sh                      |  2 +-
 t/t6112-rev-list-filters-objects.sh         |  2 +-
 t/t6413-merge-crlf.sh                       |  4 +--
 t/t7704-repack-cruft.sh                     |  2 +-
 t/t8010-cat-file-filters.sh                 |  2 +-
 t/t8013-blame-ignore-revs.sh                | 28 ++++++++---------
 t/t9118-git-svn-funky-branch-names.sh       |  2 +-
 t/t9300-fast-import.sh                      | 14 +++------
 t/t9350-fast-export.sh                      |  4 +--
 t/t9400-git-cvsserver-server.sh             | 35 ++++++++++-----------
 t/t9802-git-p4-filetype.sh                  |  2 +-
 t/t9807-git-p4-submit.sh                    |  2 +-
 t/t9824-git-p4-git-lfs.sh                   |  4 +--
 37 files changed, 85 insertions(+), 97 deletions(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 78+ messages in thread

* [PATCH v2 01/22] doc: avoid redundant use of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
@ 2024-03-15 19:45   ` Beat Bolli
  2024-03-15 19:45   ` [PATCH v2 02/22] contrib/subtree/t: " Beat Bolli
                     ` (21 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:45 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

The update-hook-example.txt script uses this anti-pattern twice. Call grep
with the input file name directy. While at it, merge the two consecutive
grep calls.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 Documentation/howto/update-hook-example.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/howto/update-hook-example.txt b/Documentation/howto/update-hook-example.txt
index 151ee84cebce..4e727deedd21 100644
--- a/Documentation/howto/update-hook-example.txt
+++ b/Documentation/howto/update-hook-example.txt
@@ -100,7 +100,7 @@ info "The user is: '$username'"
 
 if test -f "$allowed_users_file"
 then
-  rc=$(cat $allowed_users_file | grep -v '^#' | grep -v '^$' |
+  rc=$(grep -Ev '^(#|$)' $allowed_users_file |
     while read heads user_patterns
     do
       # does this rule apply to us?
@@ -138,7 +138,7 @@ info "'$groups'"
 
 if test -f "$allowed_groups_file"
 then
-  rc=$(cat $allowed_groups_file | grep -v '^#' | grep -v '^$' |
+  rc=$(grep -Ev '^(#|$)' $allowed_groups_file |
     while read heads group_patterns
     do
       # does this rule apply to us?
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 02/22] contrib/subtree/t: avoid redundant use of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
  2024-03-15 19:45   ` [PATCH v2 01/22] doc: avoid redundant use of cat Beat Bolli
@ 2024-03-15 19:45   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 03/22] t/lib-cvs.sh: " Beat Bolli
                     ` (20 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:45 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 contrib/subtree/t/t7900-subtree.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index ca4df5be8324..c3bd2a58b941 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -63,7 +63,7 @@ test_create_pre2_32_repo () {
 	git -C "$1" log -1 --format=%B HEAD^2 >msg &&
 	test_commit -C "$1-sub" --annotate sub2 &&
 	git clone --no-local "$1" "$1-clone" &&
-	new_commit=$(cat msg | sed -e "s/$commit/$tag/" | git -C "$1-clone" commit-tree HEAD^2^{tree}) &&
+	new_commit=$(sed -e "s/$commit/$tag/" msg | git -C "$1-clone" commit-tree HEAD^2^{tree}) &&
 	git -C "$1-clone" replace HEAD^2 $new_commit
 }
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 03/22] t/lib-cvs.sh: avoid redundant use of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
  2024-03-15 19:45   ` [PATCH v2 01/22] doc: avoid redundant use of cat Beat Bolli
  2024-03-15 19:45   ` [PATCH v2 02/22] contrib/subtree/t: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 04/22] t/annotate-tests.sh: " Beat Bolli
                     ` (19 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/lib-cvs.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh
index 32b347337908..57b9b2db9b3f 100644
--- a/t/lib-cvs.sh
+++ b/t/lib-cvs.sh
@@ -71,8 +71,8 @@ test_cmp_branch_tree () {
 		find . -type d -name .git -prune -o -type f -print
 	) | sort >module-git-"$1".list &&
 	test_cmp module-cvs-"$1".list module-git-"$1".list &&
-	cat module-cvs-"$1".list | while read f
+	while read f
 	do
 		test_cmp_branch_file "$1" "$f" || return 1
-	done
+	done <module-cvs-"$1".list
 }
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 04/22] t/annotate-tests.sh: avoid redundant use of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (2 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 03/22] t/lib-cvs.sh: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 05/22] t/perf: " Beat Bolli
                     ` (18 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/annotate-tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 5e21e84f3884..87572459e4b8 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -532,7 +532,7 @@ test_expect_success 'blame -L :funcname with userdiff driver' '
 		"$(cat file.template)" &&
 	test_commit --author "B <B@test.git>" \
 		"change" "$fortran_file" \
-		"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
+		"$(sed -e s/ChangeMe/IWasChanged/ file.template)" &&
 	check_count -f "$fortran_file" -L:RIGHT A 3 B 1
 '
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 05/22] t/perf: avoid redundant use of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (3 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 04/22] t/annotate-tests.sh: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 06/22] t/t0*: avoid redundant uses " Beat Bolli
                     ` (17 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Take care to redirect stdin, otherwise the output of wc would also contain
the file name.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/perf/repos/inflate-repo.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/perf/repos/inflate-repo.sh b/t/perf/repos/inflate-repo.sh
index fcfc992b5b02..412e4b450b16 100755
--- a/t/perf/repos/inflate-repo.sh
+++ b/t/perf/repos/inflate-repo.sh
@@ -33,7 +33,7 @@ do
 done
 
 git ls-tree -r HEAD >GEN_src_list
-nr_src_files=$(cat GEN_src_list | wc -l)
+nr_src_files=$(wc -l <GEN_src_list)
 
 src_branch=$(git symbolic-ref --short HEAD)
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 06/22] t/t0*: avoid redundant uses of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (4 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 05/22] t/perf: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 07/22] t/t1*: " Beat Bolli
                     ` (16 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t0002-gitfile.sh                 | 2 +-
 t/t0011-hashmap.sh                 | 2 +-
 t/t0028-working-tree-encoding.sh   | 4 ++--
 t/t0204-gettext-reencode-sanity.sh | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index 736516cc6a47..bf3bf604abe3 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -40,7 +40,7 @@ test_expect_success 'final setup + check rev-parse --git-dir' '
 
 test_expect_success 'check hash-object' '
 	echo "foo" >bar &&
-	SHA=$(cat bar | git hash-object -w --stdin) &&
+	SHA=$(git hash-object -w --stdin <bar) &&
 	test_path_is_file "$REAL/objects/$(objpath $SHA)"
 '
 
diff --git a/t/t0011-hashmap.sh b/t/t0011-hashmap.sh
index 1cb6aa682432..46e74ad1072b 100755
--- a/t/t0011-hashmap.sh
+++ b/t/t0011-hashmap.sh
@@ -239,7 +239,7 @@ test_expect_success 'grow / shrink' '
 	echo value40 >> expect &&
 	echo size >> in &&
 	echo 64 39 >> expect &&
-	cat in | test-tool hashmap > out &&
+	test-tool hashmap <in >out &&
 	test_cmp expect out
 
 '
diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh
index 1b55f59c237c..ad151a346708 100755
--- a/t/t0028-working-tree-encoding.sh
+++ b/t/t0028-working-tree-encoding.sh
@@ -131,8 +131,8 @@ do
 		test_when_finished "rm -f crlf.utf${i}.raw lf.utf${i}.raw" &&
 		test_when_finished "git reset --hard HEAD^" &&
 
-		cat lf.utf8.raw | write_utf${i} >lf.utf${i}.raw &&
-		cat crlf.utf8.raw | write_utf${i} >crlf.utf${i}.raw &&
+		write_utf${i} <lf.utf8.raw >lf.utf${i}.raw &&
+		write_utf${i} <crlf.utf8.raw >crlf.utf${i}.raw &&
 		cp crlf.utf${i}.raw eol.utf${i} &&
 
 		cat >expectIndexLF <<-EOF &&
diff --git a/t/t0204-gettext-reencode-sanity.sh b/t/t0204-gettext-reencode-sanity.sh
index 4f2e0dcb02bd..310a4500125f 100755
--- a/t/t0204-gettext-reencode-sanity.sh
+++ b/t/t0204-gettext-reencode-sanity.sh
@@ -82,7 +82,7 @@ test_expect_success GETTEXT_ISO_LOCALE 'gettext.c: git init UTF-8 -> ISO-8859-1'
     printf "Bjó til tóma Git lind" >expect &&
     LANGUAGE=is LC_ALL="$is_IS_iso_locale" git init repo >actual &&
     test_when_finished "rm -rf repo" &&
-    grep "^$(cat expect | iconv -f UTF-8 -t ISO8859-1) " actual
+    grep "^$(iconv -f UTF-8 -t ISO8859-1 <expect) " actual
 '
 
 test_done
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 07/22] t/t1*: avoid redundant uses of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (5 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 06/22] t/t0*: avoid redundant uses " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 08/22] t/t3*: " Beat Bolli
                     ` (15 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t1007-hash-object.sh             | 6 +++---
 t/t1091-sparse-checkout-builtin.sh | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index ac3d173767ae..64aea3848606 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -124,8 +124,8 @@ test_expect_success 'check that appropriate filter is invoke when --path is used
 	path0_sha=$(git hash-object --path=file0 file1) &&
 	test "$file0_sha" = "$path0_sha" &&
 	test "$file1_sha" = "$path1_sha" &&
-	path1_sha=$(cat file0 | git hash-object --path=file1 --stdin) &&
-	path0_sha=$(cat file1 | git hash-object --path=file0 --stdin) &&
+	path1_sha=$(git hash-object --path=file1 --stdin <file0) &&
+	path0_sha=$(git hash-object --path=file0 --stdin <file1) &&
 	test "$file0_sha" = "$path0_sha" &&
 	test "$file1_sha" = "$path1_sha"
 '
@@ -154,7 +154,7 @@ test_expect_success '--path works in a subdirectory' '
 test_expect_success 'check that --no-filters option works' '
 	nofilters_file1=$(git hash-object --no-filters file1) &&
 	test "$file0_sha" = "$nofilters_file1" &&
-	nofilters_file1=$(cat file1 | git hash-object --stdin) &&
+	nofilters_file1=$(git hash-object --stdin <file1) &&
 	test "$file0_sha" = "$nofilters_file1"
 '
 
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
index e49b8024ac53..ab3a105ffff2 100755
--- a/t/t1091-sparse-checkout-builtin.sh
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -968,7 +968,7 @@ test_expect_success 'check-rules non-cone mode' '
 	git -C bare sparse-checkout check-rules --no-cone --rules-file ../rules\
 		>check-rules-file <all-files &&
 
-	cat rules | git -C repo sparse-checkout set --no-cone --stdin &&
+	git -C repo sparse-checkout set --no-cone --stdin <rules &&
 	git -C repo ls-files -t >out &&
 	sed -n "/^S /!s/^. //p" out >ls-files &&
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 08/22] t/t3*: avoid redundant uses of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (6 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 07/22] t/t1*: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 09/22] t/t4*: " Beat Bolli
                     ` (14 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t3200-branch.sh           | 2 +-
 t/t3321-notes-stripspace.sh | 8 ++++----
 t/t3920-crlf-messages.sh    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index e36f4d15f2dd..c394273527cb 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -579,7 +579,7 @@ EOF
 
 	# ...and that the comments for those sections are also
 	# preserved.
-	cat config.branch | sed "s/\"source\"/\"dest\"/" >expect &&
+	sed "s/\"source\"/\"dest\"/" config.branch >expect &&
 	sed -n -e "/Note the lack/,\$p" .git/config >actual &&
 	test_cmp expect actual
 '
diff --git a/t/t3321-notes-stripspace.sh b/t/t3321-notes-stripspace.sh
index 088a852dd47a..beca34605672 100755
--- a/t/t3321-notes-stripspace.sh
+++ b/t/t3321-notes-stripspace.sh
@@ -442,7 +442,7 @@ test_expect_success 'add note by specifying "-C", "--no-stripspace" is the defau
 	${LF}
 	EOF
 
-	cat expect | git hash-object -w --stdin >blob &&
+	git hash-object -w --stdin <expect >blob &&
 	git notes add -C $(cat blob) &&
 	git notes show >actual &&
 	test_cmp expect actual &&
@@ -468,7 +468,7 @@ test_expect_success 'reuse note by specifying "-C" and "--stripspace"' '
 	second-line
 	EOF
 
-	cat data | git hash-object -w --stdin >blob &&
+	git hash-object -w --stdin <data >blob &&
 	git notes add --stripspace -C $(cat blob) &&
 	git notes show >actual &&
 	test_cmp expect actual
@@ -492,7 +492,7 @@ test_expect_success 'reuse with "-C" and add note with "-m", "-m" will stripspac
 	third-line
 	EOF
 
-	cat data | git hash-object -w --stdin >blob &&
+	git hash-object -w --stdin <data >blob &&
 	git notes add -C $(cat blob) -m "third-line" &&
 	git notes show >actual &&
 	test_cmp expect actual
@@ -511,7 +511,7 @@ test_expect_success 'add note with "-m" and reuse note with "-C", "-C" will not
 	second-line
 	EOF
 
-	cat data | git hash-object -w --stdin >blob &&
+	git hash-object -w --stdin <data >blob &&
 	git notes add -m "first-line" -C $(cat blob)  &&
 	git notes show >actual &&
 	test_cmp expect actual
diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
index 67fd2345affd..5eed640a6825 100755
--- a/t/t3920-crlf-messages.sh
+++ b/t/t3920-crlf-messages.sh
@@ -10,7 +10,7 @@ LIB_CRLF_BRANCHES=""
 create_crlf_ref () {
 	branch="$1" &&
 	cat >.crlf-orig-$branch.txt &&
-	cat .crlf-orig-$branch.txt | append_cr >.crlf-message-$branch.txt &&
+	append_cr <.crlf-orig-$branch.txt >.crlf-message-$branch.txt &&
 	grep 'Subject' .crlf-orig-$branch.txt | tr '\n' ' ' | sed 's/[ ]*$//' | tr -d '\n' >.crlf-subject-$branch.txt &&
 	grep 'Body' .crlf-orig-$branch.txt | append_cr >.crlf-body-$branch.txt &&
 	LIB_CRLF_BRANCHES="${LIB_CRLF_BRANCHES} ${branch}" &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 09/22] t/t4*: avoid redundant uses of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (7 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 08/22] t/t3*: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-16  1:34     ` Taylor Blau
  2024-03-15 19:46   ` [PATCH v2 10/22] t/t5*: " Beat Bolli
                     ` (13 subsequent siblings)
  22 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t4020-diff-external.sh         | 2 +-
 t/t4205-log-pretty-formats.sh    | 2 +-
 t/t4301-merge-tree-write-tree.sh | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index c1ac09ecc714..fdd865f7c38d 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -232,7 +232,7 @@ keep_only_cr () {
 test_expect_success 'external diff with autocrlf = true' '
 	test_config core.autocrlf true &&
 	GIT_EXTERNAL_DIFF=./fake-diff.sh git diff &&
-	test $(wc -l < crlfed.txt) = $(cat crlfed.txt | keep_only_cr | wc -c)
+	test $(wc -l <crlfed.txt) = $(keep_only_cr <crlfed.txt | wc -c)
 '
 
 test_expect_success 'diff --cached' '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index e3d655e6b8b5..1409eebcd855 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -156,7 +156,7 @@ test_expect_success 'NUL termination with --reflog --pretty=oneline' '
 	for r in $revs
 	do
 		git show -s --pretty=oneline "$r" >raw &&
-		cat raw | lf_to_nul || return 1
+		lf_to_nul <raw || return 1
 	done >expect &&
 	# the trailing NUL is already produced so we do not need to
 	# output another one
diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh
index 12ac43687366..578641467753 100755
--- a/t/t4301-merge-tree-write-tree.sh
+++ b/t/t4301-merge-tree-write-tree.sh
@@ -313,7 +313,7 @@ test_expect_success 'rename/add handling' '
 		# First, check that the bar that appears at stage 3 does not
 		# correspond to an individual blob anywhere in history
 		#
-		hash=$(cat out | tr "\0" "\n" | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
+		hash=$(tr "\0" "\n" <out | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
 		git rev-list --objects --all >all_blobs &&
 		! grep $hash all_blobs &&
 
@@ -380,7 +380,7 @@ test_expect_success SYMLINKS 'rename/add, where add is a mode conflict' '
 		# First, check that the bar that appears at stage 3 does not
 		# correspond to an individual blob anywhere in history
 		#
-		hash=$(cat out | tr "\0" "\n" | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
+		hash=$(tr "\0" "\n" <out | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
 		git rev-list --objects --all >all_blobs &&
 		! grep $hash all_blobs &&
 
@@ -630,8 +630,8 @@ test_expect_success 'mod6: chains of rename/rename(1to2) and add/add via collidi
 		# conflict entries do not appear as individual blobs anywhere
 		# in history.
 		#
-		hash1=$(cat out | tr "\0" "\n" | head | grep 2.four | cut -f 2 -d " ") &&
-		hash2=$(cat out | tr "\0" "\n" | head | grep 3.two | cut -f 2 -d " ") &&
+		hash1=$(tr "\0" "\n" <out | head | grep 2.four | cut -f 2 -d " ") &&
+		hash2=$(tr "\0" "\n" <out | head | grep 3.two | cut -f 2 -d " ") &&
 		git rev-list --objects --all >all_blobs &&
 		! grep $hash1 all_blobs &&
 		! grep $hash2 all_blobs &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 10/22] t/t5*: avoid redundant uses of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (8 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 09/22] t/t4*: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 11/22] t/t6*: " Beat Bolli
                     ` (12 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t5100-mailinfo.sh                    | 2 +-
 t/t5317-pack-objects-filter-objects.sh | 2 +-
 t/t5534-push-signed.sh                 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index 654d8cf3ee00..c8d06554541c 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -70,7 +70,7 @@ test_expect_success 'respect NULs' '
 
 	git mailsplit -d3 -o. "$DATA/nul-plain" &&
 	test_cmp "$DATA/nul-plain" 001 &&
-	(cat 001 | git mailinfo msg patch) &&
+	git mailinfo msg patch <001 &&
 	test_line_count = 4 patch
 
 '
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 2ff3eef9a3b8..79552d6ef7f6 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -455,7 +455,7 @@ test_expect_success 'setup r1 - delete loose blobs' '
 	test_parse_ls_files_stage_oids <ls_files_result |
 	sort >expected &&
 
-	for id in `cat expected | sed "s|..|&/|"`
+	for id in `sed "s|..|&/|" expected`
 	do
 		rm r1/.git/objects/$id || return 1
 	done
diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh
index b4bc24691c81..c91a62b77afc 100755
--- a/t/t5534-push-signed.sh
+++ b/t/t5534-push-signed.sh
@@ -303,7 +303,7 @@ test_expect_success GPGSM 'fail without key and heed user.signingkey x509' '
 		EOF
 		sed -n -e "s/^nonce /NONCE=/p" -e "/^$/q" dst/push-cert
 	) >expect.in &&
-	key=$(cat "${GNUPGHOME}/trustlist.txt" | cut -d" " -f1 | tr -d ":") &&
+	key=$(cut -d" " -f1 <"${GNUPGHOME}/trustlist.txt" | tr -d ":") &&
 	sed -e "s/^KEY=/KEY=${key}/" expect.in >expect &&
 
 	noop=$(git rev-parse noop) &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 11/22] t/t6*: avoid redundant uses of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (9 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 10/22] t/t5*: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 12/22] t/t7*: avoid redundant use " Beat Bolli
                     ` (11 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t6112-rev-list-filters-objects.sh | 2 +-
 t/t6413-merge-crlf.sh               | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index 52822b9461a1..43e1afd44c9b 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -670,7 +670,7 @@ test_expect_success 'rev-list W/ --missing=print' '
 	awk -f print_2.awk ls_files_result |
 	sort >expected &&
 
-	for id in `cat expected | sed "s|..|&/|"`
+	for id in `sed "s|..|&/|" expected`
 	do
 		rm r1/.git/objects/$id || return 1
 	done &&
diff --git a/t/t6413-merge-crlf.sh b/t/t6413-merge-crlf.sh
index b4f4a313f486..647ea1e83829 100755
--- a/t/t6413-merge-crlf.sh
+++ b/t/t6413-merge-crlf.sh
@@ -34,14 +34,14 @@ test_expect_success setup '
 test_expect_success 'Check "ours" is CRLF' '
 	git reset --hard initial &&
 	git merge side -s ours &&
-	cat file | remove_cr | append_cr >file.temp &&
+	remove_cr <file | append_cr >file.temp &&
 	test_cmp file file.temp
 '
 
 test_expect_success 'Check that conflict file is CRLF' '
 	git reset --hard a &&
 	test_must_fail git merge side &&
-	cat file | remove_cr | append_cr >file.temp &&
+	remove_cr <file | append_cr >file.temp &&
 	test_cmp file file.temp
 '
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 12/22] t/t7*: avoid redundant use of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (10 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 11/22] t/t6*: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 13/22] t/t8*: " Beat Bolli
                     ` (10 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t7704-repack-cruft.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t7704-repack-cruft.sh b/t/t7704-repack-cruft.sh
index be3735dff083..71e1ef3a103e 100755
--- a/t/t7704-repack-cruft.sh
+++ b/t/t7704-repack-cruft.sh
@@ -48,7 +48,7 @@ test_expect_success '--expire-to stores pruned objects (now)' '
 		# ...in other words, the combined contents of this
 		# repository and expired.git should be the same as the
 		# set of objects we started with.
-		cat expired.objects remaining.objects | sort >actual &&
+		sort expired.objects remaining.objects >actual &&
 		test_cmp expect actual &&
 
 		# The "moved" objects (i.e., those in expired.git)
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 13/22] t/t8*: avoid redundant use of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (11 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 12/22] t/t7*: avoid redundant use " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 14/22] t/t9*: avoid redundant uses " Beat Bolli
                     ` (9 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t8010-cat-file-filters.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t8010-cat-file-filters.sh b/t/t8010-cat-file-filters.sh
index ca04242ca016..eb64b766bdfa 100755
--- a/t/t8010-cat-file-filters.sh
+++ b/t/t8010-cat-file-filters.sh
@@ -43,7 +43,7 @@ test_expect_success 'cat-file --textconv --path=<path> works' '
 	sha1=$(git rev-parse -q --verify HEAD:world.txt) &&
 	test_config diff.txt.textconv "tr A-Za-z N-ZA-Mn-za-m <" &&
 	git cat-file --textconv --path=hello.txt $sha1 >rot13 &&
-	test uryyb = "$(cat rot13 | remove_cr)"
+	test uryyb = "$(remove_cr <rot13)"
 '
 
 test_expect_success '--path=<path> complains without --textconv/--filters' '
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 14/22] t/t9*: avoid redundant uses of cat
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (12 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 13/22] t/t8*: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 15/22] t/t1*: merge a "grep | sed" pipeline Beat Bolli
                     ` (8 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t9300-fast-import.sh          | 14 +++++--------
 t/t9350-fast-export.sh          |  2 +-
 t/t9400-git-cvsserver-server.sh | 35 +++++++++++++++------------------
 t/t9802-git-p4-filetype.sh      |  2 +-
 t/t9807-git-p4-submit.sh        |  2 +-
 t/t9824-git-p4-git-lfs.sh       |  4 ++--
 6 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index dbb5042b0b8f..60e30fed3c2c 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -986,7 +986,7 @@ test_expect_success 'L: nested tree copy does not corrupt deltas' '
 	test_when_finished "git update-ref -d refs/heads/L2" &&
 	git fast-import <input &&
 	git ls-tree L2 g/b/ >tmp &&
-	cat tmp | cut -f 2 >actual &&
+	cut -f 2 <tmp >actual &&
 	test_cmp expect actual &&
 	git fsck $(git rev-parse L2)
 '
@@ -2007,12 +2007,11 @@ test_expect_success 'Q: verify first notes commit' '
 '
 
 test_expect_success 'Q: verify first notes tree' '
-	cat >expect.unsorted <<-EOF &&
+	sort >expect <<-EOF &&
 	100644 blob $commit1
 	100644 blob $commit2
 	100644 blob $commit3
 	EOF
-	cat expect.unsorted | sort >expect &&
 	git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
 	test_cmp expect actual
 '
@@ -2048,12 +2047,11 @@ test_expect_success 'Q: verify second notes commit' '
 '
 
 test_expect_success 'Q: verify second notes tree' '
-	cat >expect.unsorted <<-EOF &&
+	sort >expect <<-EOF &&
 	100644 blob $commit1
 	100644 blob $commit2
 	100644 blob $commit3
 	EOF
-	cat expect.unsorted | sort >expect &&
 	git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
 	test_cmp expect actual
 '
@@ -2088,10 +2086,9 @@ test_expect_success 'Q: verify third notes commit' '
 '
 
 test_expect_success 'Q: verify third notes tree' '
-	cat >expect.unsorted <<-EOF &&
+	sort >expect <<-EOF &&
 	100644 blob $commit1
 	EOF
-	cat expect.unsorted | sort >expect &&
 	git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
 	test_cmp expect actual
 '
@@ -2115,10 +2112,9 @@ test_expect_success 'Q: verify fourth notes commit' '
 '
 
 test_expect_success 'Q: verify fourth notes tree' '
-	cat >expect.unsorted <<-EOF &&
+	sort >expect <<-EOF &&
 	100644 blob $commit2
 	EOF
-	cat expect.unsorted | sort >expect &&
 	git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]*	/ /" >actual &&
 	test_cmp expect actual
 '
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index e9a12c18bbd3..d86d07a79d4f 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -236,7 +236,7 @@ EOF
 
 test_expect_success 'set up faked signed tag' '
 
-	cat signed-tag-import | git fast-import
+	git fast-import <signed-tag-import
 
 '
 
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 003c0b61d0ff..e499c7f95512 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -117,12 +117,12 @@ END VERIFICATION REQUEST
 EOF
 
 test_expect_success 'pserver authentication' '
-	cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
+	git-cvsserver pserver <request-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'pserver authentication failure (non-anonymous user)' '
-	if cat request-git | git-cvsserver pserver >log 2>&1
+	if git-cvsserver pserver <request-git >log 2>&1
 	then
 	    false
 	else
@@ -132,17 +132,17 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' '
 '
 
 test_expect_success 'pserver authentication success (non-anonymous user with password)' '
-	cat login-git-ok | git-cvsserver pserver >log 2>&1 &&
+	git-cvsserver pserver <login-git-ok >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'pserver authentication (login)' '
-	cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
+	git-cvsserver pserver <login-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'pserver authentication failure (login/non-anonymous user)' '
-	if cat login-git | git-cvsserver pserver >log 2>&1
+	if git-cvsserver pserver <login-git >log 2>&1
 	then
 	    false
 	else
@@ -172,7 +172,7 @@ Root $WORKDIR
 EOF
 
 test_expect_success 'req_Root failure (relative pathname)' '
-	if cat request-relative | git-cvsserver pserver >log 2>&1
+	if git-cvsserver pserver <request-relative >log 2>&1
 	then
 		echo unexpected success
 		false
@@ -183,28 +183,26 @@ test_expect_success 'req_Root failure (relative pathname)' '
 '
 
 test_expect_success 'req_Root failure (conflicting roots)' '
-	cat request-conflict | git-cvsserver pserver >log 2>&1 &&
+	git-cvsserver pserver <request-conflict >log 2>&1 &&
 	tail log | grep "^error 1 Conflicting roots specified$"
 '
 
 test_expect_success 'req_Root (strict paths)' '
-	cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 &&
+	git-cvsserver --strict-paths pserver "$SERVERDIR" <request-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'req_Root failure (strict-paths)' '
-	! cat request-anonymous |
-	git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1
+	! git-cvsserver --strict-paths pserver "$WORKDIR" <request-anonymous >log 2>&1
 '
 
 test_expect_success 'req_Root (w/o strict-paths)' '
-	cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 &&
+	git-cvsserver pserver "$WORKDIR/" <request-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'req_Root failure (w/o strict-paths)' '
-	! cat request-anonymous |
-	git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1
+	! git-cvsserver pserver "$WORKDIR/gitcvs" <request-anonymous >log 2>&1
 '
 
 cat >request-base  <<EOF
@@ -217,27 +215,26 @@ Root /gitcvs.git
 EOF
 
 test_expect_success 'req_Root (base-path)' '
-	cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
+	git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <request-base >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'req_Root failure (base-path)' '
-	! cat request-anonymous |
-	git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1
+	! git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" <request-anonymous >log 2>&1
 '
 
 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
 
 test_expect_success 'req_Root (export-all)' '
-	cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 &&
+	git-cvsserver --export-all pserver "$WORKDIR" <request-anonymous >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
 test_expect_success 'req_Root failure (export-all w/o directory list)' '
-	! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
+	! (git-cvsserver --export-all pserver <request-anonymous >log 2>&1 || false)'
 
 test_expect_success 'req_Root (everything together)' '
-	cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
+	git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <request-base >log 2>&1 &&
 	sed -ne \$p log | grep "^I LOVE YOU\$"
 '
 
diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh
index 2a6ee2a46787..bb236cd2b57a 100755
--- a/t/t9802-git-p4-filetype.sh
+++ b/t/t9802-git-p4-filetype.sh
@@ -175,7 +175,7 @@ test_expect_success 'keyword file create' '
 		cp k-text-k k-text-ko &&
 		p4 add -t text+ko k-text-ko &&
 
-		cat k-text-k | iconv -f ascii -t utf-16 >k-utf16-k &&
+		iconv -f ascii -t utf-16 <k-text-k >k-utf16-k &&
 		p4 add -t utf16+k k-utf16-k &&
 
 		cp k-utf16-k k-utf16-ko &&
diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh
index af4b286f9d51..6ae7ced51be1 100755
--- a/t/t9807-git-p4-submit.sh
+++ b/t/t9807-git-p4-submit.sh
@@ -418,7 +418,7 @@ test_expect_success 'description with Jobs and values on separate lines' '
 			marshal_dump job0 <change &&
 			marshal_dump job1 <change
 		) | sort >jobs &&
-		cat jobname1 jobname2 | sort >expected &&
+		sort jobname1 jobname2 >expected &&
 		test_cmp expected jobs
 	)
 '
diff --git a/t/t9824-git-p4-git-lfs.sh b/t/t9824-git-p4-git-lfs.sh
index a28dbbdd566c..fd430403d716 100755
--- a/t/t9824-git-p4-git-lfs.sh
+++ b/t/t9824-git-p4-git-lfs.sh
@@ -17,8 +17,8 @@ test_file_in_lfs () {
 	sed -n '2,2 p' "$FILE" | grep "^oid " &&
 	sed -n '3,3 p' "$FILE" | grep "^size " &&
 	test_line_count = 3 "$FILE" &&
-	cat "$FILE" | grep "size $SIZE" &&
-	HASH=$(cat "$FILE" | grep "oid sha256:" | sed -e "s/oid sha256://g") &&
+	grep "size $SIZE" "$FILE" &&
+	HASH=$(grep "oid sha256:" "$FILE" | sed -e "s/oid sha256://g") &&
 	LFS_FILE=".git/lfs/objects/$(echo "$HASH" | cut -c1-2)/$(echo "$HASH" | cut -c3-4)/$HASH" &&
 	echo $EXPECTED_CONTENT >expect &&
 	test_path_is_file "$FILE" &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 15/22] t/t1*: merge a "grep | sed" pipeline
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (13 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 14/22] t/t9*: avoid redundant uses " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
                     ` (7 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t1509/prepare-chroot.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t1509/prepare-chroot.sh b/t/t1509/prepare-chroot.sh
index 6d47e2c725f7..dc997e0a6437 100755
--- a/t/t1509/prepare-chroot.sh
+++ b/t/t1509/prepare-chroot.sh
@@ -43,7 +43,7 @@ rsync --exclude-from t/t1509/excludes -Ha . "$R$(pwd)"
 # env might slip through, see test-lib.sh, unset.*PERL_PATH
 sed 's|^PERL_PATH=.*|PERL_PATH=/bin/true|' GIT-BUILD-OPTIONS > "$R$(pwd)/GIT-BUILD-OPTIONS"
 for cmd in git $BB;do 
-	ldd $cmd | grep '/' | sed 's,.*\s\(/[^ ]*\).*,\1,' | while read i; do
+	ldd $cmd | sed -n '/\//s,.*\s\(/[^ ]*\).*,\1,p' | while read i; do
 		mkdir -p "$R$(dirname $i)"
 		cp "$i" "$R/$i"
 	done
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (14 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 15/22] t/t1*: merge a "grep | sed" pipeline Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-16  1:49     ` Taylor Blau
  2024-03-15 19:46   ` [PATCH v2 17/22] t/t4*: merge a "grep | sed" pipeline Beat Bolli
                     ` (6 subsequent siblings)
  22 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

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
 '
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 17/22] t/t4*: merge a "grep | sed" pipeline
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (15 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 18/22] t/t5*: " Beat Bolli
                     ` (5 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t4002-diff-basic.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index 7afc883ec374..cb3307010c1e 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -405,7 +405,7 @@ test_expect_success 'diff-tree -r B A == diff-tree -r -R A B' '
 
 test_expect_success 'diff can read from stdin' '
 	test_must_fail git diff --no-index -- MN - < NN |
-		grep -v "^index" | sed "s#/-#/NN#" >.test-a &&
+		sed "/^index/d; s#/-#/NN#" >.test-a &&
 	test_must_fail git diff --no-index -- MN NN |
 		grep -v "^index" >.test-b &&
 	test_cmp .test-a .test-b
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 18/22] t/t5*: merge a "grep | sed" pipeline
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (16 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 17/22] t/t4*: merge a "grep | sed" pipeline Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
                     ` (4 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t5401-update-hooks.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index 8b8bc47dc0b9..d8cadeec7331 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -123,7 +123,7 @@ remote: STDOUT post-update
 remote: STDERR post-update
 EOF
 test_expect_success 'send-pack stderr contains hook messages' '
-	grep ^remote: send.err | sed "s/ *\$//" >actual &&
+	sed -n "/^remote:/s/ *\$//p" send.err >actual &&
 	test_cmp expect actual
 '
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 19/22] t/t8*: merge "grep | sed" pipelines
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (17 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 18/22] t/t5*: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 20/22] t/t9*: " Beat Bolli
                     ` (3 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t8013-blame-ignore-revs.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/t/t8013-blame-ignore-revs.sh b/t/t8013-blame-ignore-revs.sh
index 9a03b0f361ff..dbfbd86e83a7 100755
--- a/t/t8013-blame-ignore-revs.sh
+++ b/t/t8013-blame-ignore-revs.sh
@@ -25,11 +25,11 @@ test_expect_success setup '
 
 	git blame --line-porcelain file >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
 	git rev-parse X >expect &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
 	git rev-parse X >expect &&
 	test_cmp expect actual
 '
@@ -53,11 +53,11 @@ do
 	test_expect_success "ignore_rev_changing_lines ($I)" '
 		git blame --line-porcelain --ignore-rev $I file >blame_raw &&
 
-		grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+		sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
 		git rev-parse A >expect &&
 		test_cmp expect actual &&
 
-		grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+		sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
 		git rev-parse B >expect &&
 		test_cmp expect actual
 	'
@@ -79,10 +79,10 @@ test_expect_success ignore_rev_adding_unblamable_lines '
 	git rev-parse Y >expect &&
 	git blame --line-porcelain file --ignore-rev Y >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 3" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 3/s/ .*//p" blame_raw >actual &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 4" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 4/s/ .*//p" blame_raw >actual &&
 	test_cmp expect actual
 '
 
@@ -92,11 +92,11 @@ test_expect_success ignore_revs_from_files '
 	git rev-parse Y >ignore_y &&
 	git blame --line-porcelain file --ignore-revs-file ignore_x --ignore-revs-file ignore_y >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
 	git rev-parse A >expect &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
 	git rev-parse B >expect &&
 	test_cmp expect actual
 '
@@ -106,11 +106,11 @@ test_expect_success ignore_revs_from_configs_and_files '
 	git config --add blame.ignoreRevsFile ignore_x &&
 	git blame --line-porcelain file --ignore-revs-file ignore_y >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
 	git rev-parse A >expect &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
 	git rev-parse B >expect &&
 	test_cmp expect actual
 '
@@ -121,10 +121,10 @@ test_expect_success override_ignore_revs_file '
 	git blame --line-porcelain file --ignore-revs-file "" --ignore-revs-file ignore_y >blame_raw &&
 	git rev-parse X >expect &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 2" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 2/s/ .*//p" blame_raw >actual &&
 	test_cmp expect actual
 	'
 test_expect_success bad_files_and_revs '
@@ -279,11 +279,11 @@ test_expect_success ignore_merge '
 	test_merge M B &&
 	git blame --line-porcelain file --ignore-rev M >blame_raw &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 1" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 1/s/ .*//p" blame_raw >actual &&
 	git rev-parse B >expect &&
 	test_cmp expect actual &&
 
-	grep -E "^[0-9a-f]+ [0-9]+ 9" blame_raw | sed -e "s/ .*//" >actual &&
+	sed -ne "/^[0-9a-f][0-9a-f]* [0-9][0-9]* 9/s/ .*//p" blame_raw >actual &&
 	git rev-parse C >expect &&
 	test_cmp expect actual
 '
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 20/22] t/t9*: merge "grep | sed" pipelines
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (18 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 21/22] contrib/coverage-diff: avoid redundant pipelines Beat Bolli
                     ` (2 subsequent siblings)
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 t/t9118-git-svn-funky-branch-names.sh | 2 +-
 t/t9350-fast-export.sh                | 2 +-
 t/t9824-git-p4-git-lfs.sh             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh
index a159ff96b718..d3261e35b818 100755
--- a/t/t9118-git-svn-funky-branch-names.sh
+++ b/t/t9118-git-svn-funky-branch-names.sh
@@ -38,7 +38,7 @@ test_expect_success 'setup svnrepo' '
 # SVN 1.7 will truncate "not-a%40{0]" to just "not-a".
 # Look at what SVN wound up naming the branch and use that.
 # Be sure to escape the @ if it shows up.
-non_reflog=$(svn_cmd ls "$svnrepo/pr ject/branches" | grep not-a | sed 's/\///' | sed 's/@/%40/')
+non_reflog=$(svn_cmd ls "$svnrepo/pr ject/branches" | sed -ne '/not-a/ { s/\///; s/@/%40/; p }')
 
 test_expect_success 'test clone with funky branch names' '
 	git svn clone -s "$svnrepo/pr ject" project &&
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index d86d07a79d4f..1eb035ee4ce5 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -537,7 +537,7 @@ test_expect_success 'full-tree re-shows unmodified files'        '
 
 test_expect_success 'set-up a few more tags for tag export tests' '
 	git checkout -f main &&
-	HEAD_TREE=$(git show -s --pretty=raw HEAD | grep tree | sed "s/tree //") &&
+	HEAD_TREE=$(git show -s --pretty=raw HEAD | sed -n "/tree/s/tree //p") &&
 	git tag    tree_tag        -m "tagging a tree" $HEAD_TREE &&
 	git tag -a tree_tag-obj    -m "tagging a tree" $HEAD_TREE &&
 	git tag    tag-obj_tag     -m "tagging a tag" tree_tag-obj &&
diff --git a/t/t9824-git-p4-git-lfs.sh b/t/t9824-git-p4-git-lfs.sh
index fd430403d716..80c8c31e320f 100755
--- a/t/t9824-git-p4-git-lfs.sh
+++ b/t/t9824-git-p4-git-lfs.sh
@@ -18,7 +18,7 @@ test_file_in_lfs () {
 	sed -n '3,3 p' "$FILE" | grep "^size " &&
 	test_line_count = 3 "$FILE" &&
 	grep "size $SIZE" "$FILE" &&
-	HASH=$(grep "oid sha256:" "$FILE" | sed -e "s/oid sha256://g") &&
+	HASH=$(sed -ne "/oid sha256:/s/oid sha256://gp" "$FILE") &&
 	LFS_FILE=".git/lfs/objects/$(echo "$HASH" | cut -c1-2)/$(echo "$HASH" | cut -c3-4)/$HASH" &&
 	echo $EXPECTED_CONTENT >expect &&
 	test_path_is_file "$FILE" &&
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 21/22] contrib/coverage-diff: avoid redundant pipelines
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (19 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 20/22] t/t9*: " Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-15 19:46   ` [PATCH v2 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
  2024-03-16  1:51   ` [PATCH v2 00/22] avoid redundant pipelines Taylor Blau
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Merge multiple sed and "grep | awk" invocations, finally use "sort -u"
instead of "sort | uniq".

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 contrib/coverage-diff.sh | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/contrib/coverage-diff.sh b/contrib/coverage-diff.sh
index 4ec419f90048..6ce9603568ef 100755
--- a/contrib/coverage-diff.sh
+++ b/contrib/coverage-diff.sh
@@ -74,8 +74,7 @@ do
 	sort >uncovered_lines.txt
 
 	comm -12 uncovered_lines.txt new_lines.txt |
-	sed -e 's/$/\)/' |
-	sed -e 's/^/ /' >uncovered_new_lines.txt
+	sed -e 's/$/\)/' -e 's/^/ /' >uncovered_new_lines.txt
 
 	grep -q '[^[:space:]]' <uncovered_new_lines.txt &&
 	echo $file >>coverage-data.txt &&
@@ -91,11 +90,7 @@ cat coverage-data.txt
 
 echo "Commits introducing uncovered code:"
 
-commit_list=$(cat coverage-data.txt |
-	grep -E '^[0-9a-f]{7,} ' |
-	awk '{print $1;}' |
-	sort |
-	uniq)
+commit_list=$(awk '/^[0-9a-f]{7,}/ { print $1 }' coverage-data.txt | sort -u)
 
 (
 	for commit in $commit_list
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH v2 22/22] git-quiltimport: avoid an unnecessary subshell
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (20 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 21/22] contrib/coverage-diff: avoid redundant pipelines Beat Bolli
@ 2024-03-15 19:46   ` Beat Bolli
  2024-03-16  1:51   ` [PATCH v2 00/22] avoid redundant pipelines Taylor Blau
  22 siblings, 0 replies; 78+ messages in thread
From: Beat Bolli @ 2024-03-15 19:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Use braces for the compound command.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 git-quiltimport.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index e3d390974331..eb34cda4092a 100755
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
@@ -148,7 +148,7 @@ do
 	if [ -z "$dry_run" ] ; then
 		git apply --index -C1 ${level:+"$level"} "$tmp_patch" &&
 		tree=$(git write-tree) &&
-		commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) &&
+		commit=$( { echo "$SUBJECT"; echo; cat "$tmp_msg"; } | git commit-tree $tree -p $commit) &&
 		git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
 	fi
 done 3<"$QUILT_SERIES"
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 09/22] t/t4*: avoid redundant uses of cat
  2024-03-15 19:46   ` [PATCH v2 09/22] t/t4*: " Beat Bolli
@ 2024-03-16  1:34     ` Taylor Blau
  2024-03-16  6:04       ` Junio C Hamano
  0 siblings, 1 reply; 78+ messages in thread
From: Taylor Blau @ 2024-03-16  1:34 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Junio C Hamano, Beat Bolli

On Fri, Mar 15, 2024 at 08:46:06PM +0100, Beat Bolli wrote:
> diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh
> index 12ac43687366..578641467753 100755
> --- a/t/t4301-merge-tree-write-tree.sh
> +++ b/t/t4301-merge-tree-write-tree.sh
> @@ -313,7 +313,7 @@ test_expect_success 'rename/add handling' '
>  		# First, check that the bar that appears at stage 3 does not
>  		# correspond to an individual blob anywhere in history
>  		#
> -		hash=$(cat out | tr "\0" "\n" | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
> +		hash=$(tr "\0" "\n" <out | head -n 3 | grep 3.bar | cut -f 2 -d " ") &&
>  		git rev-list --objects --all >all_blobs &&
>  		! grep $hash all_blobs &&

This and the two similar transformations below it look good to me. This
obviously isn't the fault of your patch (nor should it necessarily be
its aim to fix), but I wonder if it would be worthwhile to extract the

    tr "\0" "\n" <out | head -n 3 | grep 3.bar | cut -f 2 -d " "

pattern into a helper function, since it's used in a few places in this
test script.

That's just a suggestion, and shouldn't hold up this patch/series. Maybe
just some #leftoverbits :-).

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline
  2024-03-15 19:46   ` [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
@ 2024-03-16  1:49     ` Taylor Blau
  2024-03-16 10:09       ` Beat Bolli
  0 siblings, 1 reply; 78+ messages in thread
From: Taylor Blau @ 2024-03-16  1:49 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Junio C Hamano, Beat Bolli

On Fri, Mar 15, 2024 at 08:46:13PM +0100, Beat Bolli wrote:
> 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 &&

I think that using `next` here is fine to ignore lines that match
`$current`, but the canonical approach would probably be using the
`!` operator instead to negate the match, like so:

    awk "!/$current/ { \$1 = \$2 = \"\" } 1" <tmp >actual &&

Not worth a reroll, of course, just something that I noticed while
reading.

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 00/22] avoid redundant pipelines
  2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
                     ` (21 preceding siblings ...)
  2024-03-15 19:46   ` [PATCH v2 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
@ 2024-03-16  1:51   ` Taylor Blau
  2024-03-16 18:06     ` Junio C Hamano
  22 siblings, 1 reply; 78+ messages in thread
From: Taylor Blau @ 2024-03-16  1:51 UTC (permalink / raw)
  To: Beat Bolli
  Cc: git, Junio C Hamano, Beat Bolli, René Scharfe,
	Elijah Newren, Philippe Blain, Johannes Schindelin

On Fri, Mar 15, 2024 at 08:45:57PM +0100, Beat Bolli wrote:
> As follow-up to [1], here's a series that eliminates redundant
> pipelines, mostly under t/.
>
> --
> 2.44.0

I read through both rounds of this series thoroughly and everything
looks all good to me. I left a couple of minor notes throughout that you
might consider changing, but I think that neither merit a reroll.

I'd be happy to see this series move forward as-is. Thanks for working
on this!

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 09/22] t/t4*: avoid redundant uses of cat
  2024-03-16  1:34     ` Taylor Blau
@ 2024-03-16  6:04       ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-16  6:04 UTC (permalink / raw)
  To: Taylor Blau; +Cc: Beat Bolli, git, Beat Bolli

Taylor Blau <me@ttaylorr.com> writes:

> This and the two similar transformations below it look good to me. This
> obviously isn't the fault of your patch (nor should it necessarily be
> its aim to fix), but I wonder if it would be worthwhile to extract the
>
>     tr "\0" "\n" <out | head -n 3 | grep 3.bar | cut -f 2 -d " "
>
> pattern into a helper function, since it's used in a few places in this
> test script.

I somehow thought that the theme of the topic is to reduce the depth
of the pipeline.  "head -n 3" piped into "grep" sounds something a
single sed script can do, e.g.

	tr '\000' '\012' <out |	sed -n -e '1,3s/3.bar/&/p'

> That's just a suggestion, and shouldn't hold up this patch/series. Maybe
> just some #leftoverbits :-).

Ditto.  The whole thing can be turned into a Perl scriptlet, which
may be even easier to read (the cost to spin up one Perl interpreter
might be greater than constructing 4 process pipeline on certain
systems, though).

Thanks.

P.S. It is nice to hear from you Taylor.  It's been a while.


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline
  2024-03-16  1:49     ` Taylor Blau
@ 2024-03-16 10:09       ` Beat Bolli
  2024-03-16 15:46         ` Taylor Blau
  0 siblings, 1 reply; 78+ messages in thread
From: Beat Bolli @ 2024-03-16 10:09 UTC (permalink / raw)
  To: Taylor Blau; +Cc: git, Junio C Hamano

On 16.03.24 02:49, Taylor Blau wrote:
> On Fri, Mar 15, 2024 at 08:46:13PM +0100, Beat Bolli wrote:
>> 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 &&
> 
> I think that using `next` here is fine to ignore lines that match
> `$current`, but the canonical approach would probably be using the
> `!` operator instead to negate the match, like so:
> 
>      awk "!/$current/ { \$1 = \$2 = \"\" } 1" <tmp >actual &&
> 
> Not worth a reroll, of course, just something that I noticed while
> reading.

Except it's not the same :-) This was actually my first try, but then I 
realized that awk continues to evaluate patterns and actions until the 
end of the script. The "1" at the end is the "always true" pattern that 
causes the default action "print $0" to run.

So the "next" is needed to discard the current line.

Having said this,

     awk "!/$current/ { \$1 = \$2 = \"\"; print \$0 }" <tmp >actual &&

would work, and it would also remove the obscure flow detailed above.


Regards, Beat

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline
  2024-03-16 10:09       ` Beat Bolli
@ 2024-03-16 15:46         ` Taylor Blau
  0 siblings, 0 replies; 78+ messages in thread
From: Taylor Blau @ 2024-03-16 15:46 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Junio C Hamano

On Sat, Mar 16, 2024 at 11:09:47AM +0100, Beat Bolli wrote:
> On 16.03.24 02:49, Taylor Blau wrote:
> > On Fri, Mar 15, 2024 at 08:46:13PM +0100, Beat Bolli wrote:
> > > 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 &&
> >
> > I think that using `next` here is fine to ignore lines that match
> > `$current`, but the canonical approach would probably be using the
> > `!` operator instead to negate the match, like so:
> >
> >      awk "!/$current/ { \$1 = \$2 = \"\" } 1" <tmp >actual &&
> >
> > Not worth a reroll, of course, just something that I noticed while
> > reading.
>
> Except it's not the same :-) This was actually my first try, but then I
> realized that awk continues to evaluate patterns and actions until the end
> of the script. The "1" at the end is the "always true" pattern that causes
> the default action "print $0" to run.
>
> So the "next" is needed to discard the current line.
>
> Having said this,
>
>     awk "!/$current/ { \$1 = \$2 = \"\"; print \$0 }" <tmp >actual &&
>
> would work, and it would also remove the obscure flow detailed above.
>

Ah. Thanks for the explanation. These details would not hurt to have in
a commit message, but I think that this change is fine as-is. Those
curious enough can likely find this thread on the list for this
particular instance.

But these sort of less-than-trivial details are exactly the sorts of
things we like to capture in a well-written patch message.

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 00/22] avoid redundant pipelines
  2024-03-16  1:51   ` [PATCH v2 00/22] avoid redundant pipelines Taylor Blau
@ 2024-03-16 18:06     ` Junio C Hamano
  0 siblings, 0 replies; 78+ messages in thread
From: Junio C Hamano @ 2024-03-16 18:06 UTC (permalink / raw)
  To: Taylor Blau
  Cc: Beat Bolli, git, Beat Bolli, René Scharfe, Elijah Newren,
	Philippe Blain, Johannes Schindelin

Taylor Blau <me@ttaylorr.com> writes:

> On Fri, Mar 15, 2024 at 08:45:57PM +0100, Beat Bolli wrote:
>> As follow-up to [1], here's a series that eliminates redundant
>> pipelines, mostly under t/.
>>
>> --
>> 2.44.0
>
> I read through both rounds of this series thoroughly and everything
> looks all good to me. I left a couple of minor notes throughout that you
> might consider changing, but I think that neither merit a reroll.
>
> I'd be happy to see this series move forward as-is. Thanks for working
> on this!

Yeah, looks good.  Thanks, both.


^ permalink raw reply	[flat|nested] 78+ messages in thread

end of thread, other threads:[~2024-03-16 18:07 UTC | newest]

Thread overview: 78+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 21:24 [PATCH 00/22] avoid redundant pipelines Beat Bolli
2024-03-05 21:25 ` [PATCH 01/22] doc: avoid redundant use of cat Beat Bolli
2024-03-05 22:24   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 02/22] contrib/subtree/t: " Beat Bolli
2024-03-05 22:25   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 03/22] t/lib-cvs.sh: " Beat Bolli
2024-03-05 22:26   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 04/22] t/annotate-tests.sh: " Beat Bolli
2024-03-05 22:28   ` Junio C Hamano
2024-03-06  0:04     ` Rubén Justo
2024-03-06  0:26       ` Junio C Hamano
2024-03-06  0:38         ` Rubén Justo
2024-03-05 21:25 ` [PATCH 05/22] t/perf: " Beat Bolli
2024-03-05 22:29   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 06/22] t/t0*: avoid redundant uses " Beat Bolli
2024-03-05 21:25 ` [PATCH 07/22] t/t1*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 08/22] t/t3*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 09/22] t/t4*: " Beat Bolli
2024-03-06  0:49   ` Junio C Hamano
2024-03-06  1:08   ` Eric Sunshine
2024-03-06 20:58     ` Beat Bolli
2024-03-05 21:25 ` [PATCH 10/22] t/t5*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 11/22] t/t6*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 12/22] t/t7*: avoid redundant use " Beat Bolli
2024-03-05 21:25 ` [PATCH 13/22] t/t8*: " Beat Bolli
2024-03-05 21:25 ` [PATCH 14/22] t/t9*: avoid redundant uses " Beat Bolli
2024-03-05 22:52   ` Rubén Justo
2024-03-06  0:43     ` Junio C Hamano
2024-03-06  1:10       ` Rubén Justo
2024-03-05 21:25 ` [PATCH 15/22] t/t1*: merge a "grep | sed" pipeline Beat Bolli
2024-03-05 21:25 ` [PATCH 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
2024-03-06  0:55   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 17/22] t/t4*: merge a "grep | sed" pipeline Beat Bolli
2024-03-05 21:25 ` [PATCH 18/22] t/t5*: " Beat Bolli
2024-03-06  0:57   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
2024-03-06  0:59   ` Junio C Hamano
2024-03-06  2:17     ` Todd Zullinger
2024-03-06 16:03       ` Junio C Hamano
2024-03-06 21:03       ` Beat Bolli
2024-03-06 21:47         ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 20/22] t/t9*: " Beat Bolli
2024-03-06  1:00   ` Junio C Hamano
2024-03-05 21:25 ` [PATCH 21/22] contrib/coverage-diff: avoid redundant pipelines Beat Bolli
2024-03-05 21:25 ` [PATCH 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
2024-03-05 22:55   ` Rubén Justo
2024-03-05 22:58 ` [PATCH 00/22] avoid redundant pipelines Rubén Justo
2024-03-05 23:51 ` Junio C Hamano
2024-03-15 19:45 ` [PATCH v2 " Beat Bolli
2024-03-15 19:45   ` [PATCH v2 01/22] doc: avoid redundant use of cat Beat Bolli
2024-03-15 19:45   ` [PATCH v2 02/22] contrib/subtree/t: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 03/22] t/lib-cvs.sh: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 04/22] t/annotate-tests.sh: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 05/22] t/perf: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 06/22] t/t0*: avoid redundant uses " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 07/22] t/t1*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 08/22] t/t3*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 09/22] t/t4*: " Beat Bolli
2024-03-16  1:34     ` Taylor Blau
2024-03-16  6:04       ` Junio C Hamano
2024-03-15 19:46   ` [PATCH v2 10/22] t/t5*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 11/22] t/t6*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 12/22] t/t7*: avoid redundant use " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 13/22] t/t8*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 14/22] t/t9*: avoid redundant uses " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 15/22] t/t1*: merge a "grep | sed" pipeline Beat Bolli
2024-03-15 19:46   ` [PATCH v2 16/22] t/t3*: merge a "grep | awk" pipeline Beat Bolli
2024-03-16  1:49     ` Taylor Blau
2024-03-16 10:09       ` Beat Bolli
2024-03-16 15:46         ` Taylor Blau
2024-03-15 19:46   ` [PATCH v2 17/22] t/t4*: merge a "grep | sed" pipeline Beat Bolli
2024-03-15 19:46   ` [PATCH v2 18/22] t/t5*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 19/22] t/t8*: merge "grep | sed" pipelines Beat Bolli
2024-03-15 19:46   ` [PATCH v2 20/22] t/t9*: " Beat Bolli
2024-03-15 19:46   ` [PATCH v2 21/22] contrib/coverage-diff: avoid redundant pipelines Beat Bolli
2024-03-15 19:46   ` [PATCH v2 22/22] git-quiltimport: avoid an unnecessary subshell Beat Bolli
2024-03-16  1:51   ` [PATCH v2 00/22] avoid redundant pipelines Taylor Blau
2024-03-16 18:06     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).