git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH] t5500-fetch-pack.sh: fix suppression of Git exit code in tests

From
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Date
Jan 13, 2026, 09:53 UTC
Message-ID
<20260113100145.436591-1-shreyanshpaliwalcmsmn@gmail.com>
In-Reply-To
<xmqqpl7fnetj.fsf@gitster.g>
Show 25 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
>
> > On Sun, Jan 11, 2026 at 02:50:37PM -0800, Junio C Hamano wrote:
> >> Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes:
> >> >  	GIT_PROTOCOL=version=2 git upload-pack . <<-EOF >/dev/null
> >> >  	0012command=fetch
> >> > -	$(echo "object-format=$(test_oid algo)" | packetize)
> >> > +	$(echo "object-format=$(<oid_algo)" | packetize)
> >>
> >> The construct $(<file) is bashism, that does not work if your shell
> >> is not bash, isn't it?  If you used a variable, e.g.,
> >>
> >> 	$(echo "object-format=$oid_algo" | packetize)
> >>
> >> that would make the result more portable.
> >
> > There's no need for the echo at all as this can also be written as:
> >
> >     packetize "object-format=$oid_algo"
>
> Yeah, I failed to realize that this is a(n unnecessarily) convoluted
> use of command substitution inside HERE-DOC.  What mushroom were we
> on when we originally wrote this crap, I have to wonder ;-)?
>
> Thanks for spotting it.

I tried using packetize directly inside the here-doc but it was throwing the error,

	fatal: protocol error: bad line length character

this is probably because packetize is creating an extra newline in here-doc which includes unnecessary extra bytes which is throwing off the v2 protocol, and this is why I think echo was initially used there convolutedly.

I think a much better approach, is to use test-tool pkt-line pack, which I believe handles the formatting issues internally, thus making sure the requirements for the v2 protocol are followed.

Additionally, this solves the git exit code suppressing issue as well.
Below is the revised patch let me know what do you think.

Best, Shreyansh

Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
---
 t/t5500-fetch-pack.sh | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 2677cd5faa..62cf0e1ff7 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -892,15 +892,20 @@ test_expect_success 'shallow since with commit graph and already-seen commit' '
 	test_commit other &&
 	git commit-graph write --reachable &&
 	git config core.commitGraph true &&
-
-	GIT_PROTOCOL=version=2 git upload-pack . <<-EOF >/dev/null
-	0012command=fetch
-	$(echo "object-format=$(test_oid algo)" | packetize)
-	00010013deepen-since 1
-	$(echo "want $(git rev-parse other)" | packetize)
-	$(echo "have $(git rev-parse main)" | packetize)
+	oid_algo=$(test_oid algo) &&
+	oid_other=$(git rev-parse other) &&
+	oid_main=$(git rev-parse main) &&
+
+	test-tool pkt-line pack >input <<-EOF &&
+	command=fetch
+	object-format=$oid_algo
+	0001
+	deepen-since 1
+	want $oid_other
+	have $oid_main
 	0000
 	EOF
+	GIT_PROTOCOL=version=2 git upload-pack . <input >/dev/null
 	)
 '
 
-- 
2.43.0
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 12 in “t5500-fetch-pack.sh: fix suppression of Git exit code in tests”
  1. t5500-fetch-pack.sh: fix suppression of Git exit code in testsShreyansh Paliwal, Jan 11, 2026
  2. Junio C HamanoJan 11, 2026
  3. Patrick SteinhardtJan 12, 2026
  4. Shreyansh PaliwalJan 12, 2026
  5. Junio C HamanoJan 12, 2026
  6. Shreyansh PaliwalJan 13, 2026
  7. Junio C HamanoJan 13, 2026
  8. [GSOC][PATCH] t5500: simplify test implementation and fix git exit code suppressionShreyansh Paliwal, Jan 13, 2026
  9. Shreyansh PaliwalJan 15, 2026
  10. Junio C HamanoJan 20, 2026
  11. [GSOC][PATCH V2] t5500: simplify test implementation and fix git exit code suppressionShreyansh Paliwal, Jan 21, 2026
  12. t5500-fetch-pack.sh: fix suppression of Git exit code in testsShreyansh Paliwal, Jan 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.