Subject: Re: [PATCH 2/2] bundle tests: use test_cmp instead of grep

From: Taylor Blau <[email-masked]>
Date: Thu, 22 Jul 2021 14:13:12 -0400

On Thu, Jul 22, 2021 at 01:53:54AM +0200, Ævar Arnfjörð Bjarmason wrote:
> > Or, if you wanted to go further, you could do something like:
> >
> >     cat >expect <<-EOF
> >     $(test_have_prereq SHA1 || echo "@object-format=sha256")
> >     -$(git log --pretty=format:"%H %s" -1 HEAD^)
> >     $(git rev-parse HEAD) HEAD
> >     EOF
> >
> > which is arguably a little tighter (although I find the
> > echo-in-a-heredoc thing to be kind of ugly).
>
> This one won't work because you'll have an empty line at the start under
> SHA-1.

Ah, you're totally right: good catch. I think it's avoidable by smashing
the first two lines into one. If the subshell prints nothing, then the
first line will start with "-$(git log ...)", otherwise, if it does
print something, then the echo will print a newline to separate it from
the "-$(git log ...) output which will go on the second line.

But that is definitely uglier than my first suggestion, so I'm glad that
you didn't try and make what I wrote above work :).

Thanks,
Taylor