t5701: use test_file_size() to get the size of a file

The 'basics of object-info' test runs 'wc -c | xargs' twice to get the size of two.t. The pipe to xargs is only there to strip the blanks that some platforms pad the output of wc with. Use the test_file_size() helper, which outputs the size directly, and store the result in a variable. Because 'git rev-parse two:two.t' is also run twice, store its output in a variable as well. Mentored-by: Karthik Nayak <karthik.188@gmail.com> Mentored-by: Chandra Pratap <chandrapratap3519@gmail.com> Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pablo Sabater committed Aug 3, 2026 at 16:39 UTC 1d2c9a4192353aa814db1a3bf46f6cbb925c53c4
1 file changed +7 -4
t/t5701-git-serve.sh
+7 -4
@@ -344,20 +344,23 @@ test_expect_success 'unexpected lines are not allowed in fetch request' '
344 test_expect_success 'basics of object-info' '
345 test_config transfer.advertiseObjectInfo true &&
346
347 + two_oid=$(git rev-parse two:two.t) &&
348 + two_size=$(test_file_size two.t) &&
349 +
350 test-tool pkt-line pack >in <<-EOF &&
351 command=object-info
352 object-format=$(test_oid algo)
353 0001
354 size
352 - oid $(git rev-parse two:two.t)
353 - oid $(git rev-parse two:two.t)
355 + oid $two_oid
356 + oid $two_oid
357 0000
358 EOF
359
360 cat >expect <<-EOF &&
361 size
359 - $(git rev-parse two:two.t) $(wc -c <two.t | xargs)
360 - $(git rev-parse two:two.t) $(wc -c <two.t | xargs)
362 + $two_oid $two_size
363 + $two_oid $two_size
364 0000
365 EOF
366