Jeff King <peff@xxxxxxxx> 于2021年5月31日周一 下午10:44写道: > > > > > +test_expect_success 'cat-file --batch="batman" with --batch-all-objects will work' ' > > > > + git -C all-two cat-file --batch-all-objects --batch="%(objectname)" | wc -l >expect && > > > > + git -C all-two cat-file --batch-all-objects --batch="batman" | wc -l >actual && > > > > + test_cmp expect actual > > > > +' > > > > > > Is it worth testing both of these? The %(objectname) one will fail in > > > the same way (because we do not need to run oid_object_info() to get the > > > oid, which we already have). I'm OK doing both for better coverage, but > > > it may be worth mentioning either in a comment or in the commit message > > > that we expect both to fail, and why. > > > > Yes, these damages need to be pointed out in the commit message. > > I think what confused me here is that you are using "%(objectname)" as > the "expect" output, but it also exhibits the bug. So I'd expect this > test to pass even before your patch (though I didn't try it). > Yes, %(objectname) should not be used as the output of "expect", it is also a broken part. > Really, the symptom of the bug is that _neither_ of those cat-file > invocations will exit with a success code. But because they're on the > left-hand side of a pipe, we wouldn't even notice. > > The simplest test is just: > > git -C all-two cat-file --batch-all-objects --batch="%(objectname)" >/dev/null > Yes, this is enough. I even think about use something like "!test_must_fail xxx" before... that is not necessary. > which will currently fail. It would be nice to verify that its output is > sensible, but I'm not sure how to easily do that (it will spew a bunch > of binary tree data, and it cannot even be parsed reliably since we > haven't output the sizes). > > -Peff Thanks! -- ZheNing Hu