Subject: Re: [PATCH v3 04/17] cat-file tests: test that --allow-unknown-type isn't on by default

From: Jonathan Nieder <[email-masked]>
Date: Thu, 27 May 2021 14:17:41 -0700

Hi,

Ævar Arnfjörð Bjarmason wrote:

> Fix a blindspot in the tests added in the tests for the
> --allow-unknown-type feature, added in 39e4ae38804 (cat-file: teach
> cat-file a '--allow-unknown-type' option, 2015-05-03).
>
> Before this change all the tests would succeed if --allow-unknown-type
> was on by default, let's fix that by asserting that -t and -s die on a
> "garbage" type without --allow-unknown-type.

nit: "tests added in the tests" seems oddly repetitive.

More importantly, I'm curious about the desired behavior here.  The
idea behind cat-file --allow-unknown-type is that I can use it to
inspect an invalid object, for example after it has been reported by
git fsck.  The commit that introduced it (39e4ae3880, "cat-file: teach
cat-file a '--allow-unknown-type' option", 2015-05-03) gives the hint
"query broken/corrupt objects" in the documentation, so I figure
that's what it's for, and I'm sympathetic.

But: why is that an option instead of something that we always do?

In other words, is there some situation where I would not want the
more permissive behavior from cat-file against a bad object?

Thanks,
Jonathan