Re: [PATCH 2/2] bundle tests: use test_cmp instead of grep
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Jul 22, 2021, 18:13 UTC
- Message-ID
- <YPm1ODTi2wX103My@nand.local>
- In-Reply-To
- <87fsw7ussi.fsf@evledraar.gmail.com>
On Thu, Jul 22, 2021 at 01:53:54AM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 13 quoted lines
> > 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