t/t9*: avoid redundant uses of cat

Signed-off-by: Beat Bolli <dev+git@drbeat.li> Acked-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Beat Bolli committed Mar 15, 2024 at 20:46 UTC af7dd8bd73c7007c90194630de63570477430cef
6 files changed +26 -33
t/t9300-fast-import.sh
+5 -9
@@ -986,7 +986,7 @@ test_expect_success 'L: nested tree copy does not corrupt deltas' '
986 test_when_finished "git update-ref -d refs/heads/L2" &&
987 git fast-import <input &&
988 git ls-tree L2 g/b/ >tmp &&
989 - cat tmp | cut -f 2 >actual &&
989 + cut -f 2 <tmp >actual &&
990 test_cmp expect actual &&
991 git fsck $(git rev-parse L2)
992 '
@@ -2007,12 +2007,11 @@ test_expect_success 'Q: verify first notes commit' '
2007 '
2008
2009 test_expect_success 'Q: verify first notes tree' '
2010 - cat >expect.unsorted <<-EOF &&
2010 + sort >expect <<-EOF &&
2011 100644 blob $commit1
2012 100644 blob $commit2
2013 100644 blob $commit3
2014 EOF
2015 - cat expect.unsorted | sort >expect &&
2015 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2016 test_cmp expect actual
2017 '
@@ -2048,12 +2047,11 @@ test_expect_success 'Q: verify second notes commit' '
2047 '
2048
2049 test_expect_success 'Q: verify second notes tree' '
2051 - cat >expect.unsorted <<-EOF &&
2050 + sort >expect <<-EOF &&
2051 100644 blob $commit1
2052 100644 blob $commit2
2053 100644 blob $commit3
2054 EOF
2056 - cat expect.unsorted | sort >expect &&
2055 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2056 test_cmp expect actual
2057 '
@@ -2088,10 +2086,9 @@ test_expect_success 'Q: verify third notes commit' '
2086 '
2087
2088 test_expect_success 'Q: verify third notes tree' '
2091 - cat >expect.unsorted <<-EOF &&
2089 + sort >expect <<-EOF &&
2090 100644 blob $commit1
2091 EOF
2094 - cat expect.unsorted | sort >expect &&
2092 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2093 test_cmp expect actual
2094 '
@@ -2115,10 +2112,9 @@ test_expect_success 'Q: verify fourth notes commit' '
2112 '
2113
2114 test_expect_success 'Q: verify fourth notes tree' '
2118 - cat >expect.unsorted <<-EOF &&
2115 + sort >expect <<-EOF &&
2116 100644 blob $commit2
2117 EOF
2121 - cat expect.unsorted | sort >expect &&
2118 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2119 test_cmp expect actual
2120 '
t/t9350-fast-export.sh
+1 -1
@@ -236,7 +236,7 @@ EOF
236
237 test_expect_success 'set up faked signed tag' '
238
239 - cat signed-tag-import | git fast-import
239 + git fast-import <signed-tag-import
240
241 '
242
t/t9400-git-cvsserver-server.sh
+16 -19
@@ -117,12 +117,12 @@ END VERIFICATION REQUEST
117 EOF
118
119 test_expect_success 'pserver authentication' '
120 - cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
120 + git-cvsserver pserver <request-anonymous >log 2>&1 &&
121 sed -ne \$p log | grep "^I LOVE YOU\$"
122 '
123
124 test_expect_success 'pserver authentication failure (non-anonymous user)' '
125 - if cat request-git | git-cvsserver pserver >log 2>&1
125 + if git-cvsserver pserver <request-git >log 2>&1
126 then
127 false
128 else
@@ -132,17 +132,17 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' '
132 '
133
134 test_expect_success 'pserver authentication success (non-anonymous user with password)' '
135 - cat login-git-ok | git-cvsserver pserver >log 2>&1 &&
135 + git-cvsserver pserver <login-git-ok >log 2>&1 &&
136 sed -ne \$p log | grep "^I LOVE YOU\$"
137 '
138
139 test_expect_success 'pserver authentication (login)' '
140 - cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
140 + git-cvsserver pserver <login-anonymous >log 2>&1 &&
141 sed -ne \$p log | grep "^I LOVE YOU\$"
142 '
143
144 test_expect_success 'pserver authentication failure (login/non-anonymous user)' '
145 - if cat login-git | git-cvsserver pserver >log 2>&1
145 + if git-cvsserver pserver <login-git >log 2>&1
146 then
147 false
148 else
@@ -172,7 +172,7 @@ Root $WORKDIR
172 EOF
173
174 test_expect_success 'req_Root failure (relative pathname)' '
175 - if cat request-relative | git-cvsserver pserver >log 2>&1
175 + if git-cvsserver pserver <request-relative >log 2>&1
176 then
177 echo unexpected success
178 false
@@ -183,28 +183,26 @@ test_expect_success 'req_Root failure (relative pathname)' '
183 '
184
185 test_expect_success 'req_Root failure (conflicting roots)' '
186 - cat request-conflict | git-cvsserver pserver >log 2>&1 &&
186 + git-cvsserver pserver <request-conflict >log 2>&1 &&
187 tail log | grep "^error 1 Conflicting roots specified$"
188 '
189
190 test_expect_success 'req_Root (strict paths)' '
191 - cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 &&
191 + git-cvsserver --strict-paths pserver "$SERVERDIR" <request-anonymous >log 2>&1 &&
192 sed -ne \$p log | grep "^I LOVE YOU\$"
193 '
194
195 test_expect_success 'req_Root failure (strict-paths)' '
196 - ! cat request-anonymous |
197 - git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1
196 + ! git-cvsserver --strict-paths pserver "$WORKDIR" <request-anonymous >log 2>&1
197 '
198
199 test_expect_success 'req_Root (w/o strict-paths)' '
201 - cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 &&
200 + git-cvsserver pserver "$WORKDIR/" <request-anonymous >log 2>&1 &&
201 sed -ne \$p log | grep "^I LOVE YOU\$"
202 '
203
204 test_expect_success 'req_Root failure (w/o strict-paths)' '
206 - ! cat request-anonymous |
207 - git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1
205 + ! git-cvsserver pserver "$WORKDIR/gitcvs" <request-anonymous >log 2>&1
206 '
207
208 cat >request-base <<EOF
@@ -217,27 +215,26 @@ Root /gitcvs.git
215 EOF
216
217 test_expect_success 'req_Root (base-path)' '
220 - cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
218 + git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <request-base >log 2>&1 &&
219 sed -ne \$p log | grep "^I LOVE YOU\$"
220 '
221
222 test_expect_success 'req_Root failure (base-path)' '
225 - ! cat request-anonymous |
226 - git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1
223 + ! git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" <request-anonymous >log 2>&1
224 '
225
226 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
227
228 test_expect_success 'req_Root (export-all)' '
232 - cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 &&
229 + git-cvsserver --export-all pserver "$WORKDIR" <request-anonymous >log 2>&1 &&
230 sed -ne \$p log | grep "^I LOVE YOU\$"
231 '
232
233 test_expect_success 'req_Root failure (export-all w/o directory list)' '
237 - ! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
234 + ! (git-cvsserver --export-all pserver <request-anonymous >log 2>&1 || false)'
235
236 test_expect_success 'req_Root (everything together)' '
240 - cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
237 + git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <request-base >log 2>&1 &&
238 sed -ne \$p log | grep "^I LOVE YOU\$"
239 '
240
t/t9802-git-p4-filetype.sh
+1 -1
@@ -175,7 +175,7 @@ test_expect_success 'keyword file create' '
175 cp k-text-k k-text-ko &&
176 p4 add -t text+ko k-text-ko &&
177
178 - cat k-text-k | iconv -f ascii -t utf-16 >k-utf16-k &&
178 + iconv -f ascii -t utf-16 <k-text-k >k-utf16-k &&
179 p4 add -t utf16+k k-utf16-k &&
180
181 cp k-utf16-k k-utf16-ko &&
t/t9807-git-p4-submit.sh
+1 -1
@@ -418,7 +418,7 @@ test_expect_success 'description with Jobs and values on separate lines' '
418 marshal_dump job0 <change &&
419 marshal_dump job1 <change
420 ) | sort >jobs &&
421 - cat jobname1 jobname2 | sort >expected &&
421 + sort jobname1 jobname2 >expected &&
422 test_cmp expected jobs
423 )
424 '
t/t9824-git-p4-git-lfs.sh
+2 -2
@@ -17,8 +17,8 @@ test_file_in_lfs () {
17 sed -n '2,2 p' "$FILE" | grep "^oid " &&
18 sed -n '3,3 p' "$FILE" | grep "^size " &&
19 test_line_count = 3 "$FILE" &&
20 - cat "$FILE" | grep "size $SIZE" &&
21 - HASH=$(cat "$FILE" | grep "oid sha256:" | sed -e "s/oid sha256://g") &&
20 + grep "size $SIZE" "$FILE" &&
21 + HASH=$(grep "oid sha256:" "$FILE" | sed -e "s/oid sha256://g") &&
22 LFS_FILE=".git/lfs/objects/$(echo "$HASH" | cut -c1-2)/$(echo "$HASH" | cut -c3-4)/$HASH" &&
23 echo $EXPECTED_CONTENT >expect &&
24 test_path_is_file "$FILE" &&