Re: [PATCH v3 04/17] cat-file tests: test that --allow-unknown-type isn't on by default
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- May 27, 2021, 21:17 UTC
- Message-ID
- <YLAMdYtd77l2g6SP@google.com>
- In-Reply-To
- <patch-04.17-871b820003-20210520T111610Z-avarab@gmail.com>
Hi,
Ævar Arnfjörð Bjarmason wrote:
Show 7 quoted lines
> 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