Re: [PATCH v2 4/5] tests: replace remaining packetize() with "test-tool pkt-line"
- From
Jeff King <peff@peff.net>
- Date
- Jul 14, 2021, 01:16 UTC
- Message-ID
- <YO460pigGesWU/5H@coredump.intra.peff.net>
- In-Reply-To
- <8735sh3h09.fsf@evledraar.gmail.com>
On Wed, Jul 14, 2021 at 01:52:09AM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 20 quoted lines
> > I.e.:
> >
> > {
> > printf "git-upload-pack /interp.git\n\0host=localhost" |
> > test-tool pkt-line pack-raw-stdin &&
> > printf "0000" | test-tool pkt-line pack
> > } >input
> >
> > (again here the packing of "0000" is pointless, but I'm OK with it for
> > consistency).
>
> Sure, I can use {} blocks, but re the reply on 3/5 about "0000"
> v.s. "0000\n" you'd like to move back to print not-a-newline here
> v.s. having the helper eat lines ending with \n like everywhere else?
>
> It's not incorrect in this case, it just seems less obvious to
> me. I.e. the printf in the former case is because we explicitly care
> about the exact raw input, if there's a trailing \n or not, in the
> latter case we don't, so I think it's clearier to use the usual <<-\EOF
> pattern rather than printf.I don't think it's incorrect in any of the cases. I was just noting that "printf 0000" is fewer characters and fewer processes than either piping to pkt-line or using a here-doc.
I don't feel strongly on using it if you want to keep things consistent between the tests. Nor on using a here-doc versus piping (I don't see any problem with switching between them based on which is shorter or more readable in any given instance; if you're piping, it could also be "echo").
-Peff