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

Re: [PATCH 1/2] test-lib-functions: make packetize() more efficient

From
Jeff King <peff@peff.net>
Date
Mar 28, 2020, 12:25 UTC
Message-ID
<20200328122534.GA642919@coredump.intra.peff.net>
In-Reply-To
<20200327151607.GA30419@syl.local>
On Fri, Mar 27, 2020 at 09:16:07AM -0600, Taylor Blau wrote:
Show 19 quoted lines
> >  packetize() {
> > -	cat >packetize.tmp &&
> > -	len=$(wc -c <packetize.tmp) &&
> > -	printf '%04x%s' "$(($len + 4))" &&
> > -	cat packetize.tmp &&
> > -	rm -f packetize.tmp
> > +	if test $# -gt 0
> > +	then
> > +		packet="$*"
> 
> Mentioned off-list in a discussion already, but: though I find this
> behavior of joining multiple arguments by a whitespace character a
> little confusing (i.e., what would callers thing this function does if
> they hadn't read the documentation?) I think that this is probably the
> most sane thing that you could do here.
> 
> On the other hand, nowhere in this patch do we currently call packetize
> with multiple arguments, so perhaps it would be made simpler if we
> instead wrote "$1" anywhere there was "$packet".
Of all the options, I like that the least because somebody doing:
  packetize foo bar

would have the "bar" silently ignored. And it's more lines of code to check and complain about that than it is to just do something sensible.

-Peff
Previous: Taylor BlauNext: Junio C Hamano
Message 4 of 16 in “upload-pack: handle unexpected v2 delim packets”
  1. 0/2 upload-pack: handle unexpected v2 delim packetsJeff King, Mar 27, 2020
  2. 1/2 test-lib-functions: make packetize() more efficientJeff King, Mar 27, 2020
  3. Taylor BlauMar 27, 2020
  4. Jeff KingMar 28, 2020
  5. Junio C HamanoMar 27, 2020
  6. Jeff KingMar 28, 2020
  7. Junio C HamanoMar 29, 2020
  8. Junio C HamanoMar 29, 2020
  9. Jeff KingMar 29, 2020
  10. Junio C HamanoMar 29, 2020
  11. Jeff KingMar 29, 2020
  12. test-lib-functions: simplify packetize() stdin codeJeff King, Mar 29, 2020
  13. Junio C HamanoMar 29, 2020
  14. 2/2 upload-pack: handle unexpected delim packetsJeff King, Mar 27, 2020
  15. Taylor BlauMar 27, 2020
  16. Taylor BlauMar 27, 2020

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.