Re: [PATCH 1/2] [GSOC] cat-file: fix --batch report changed-type bug
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- Jun 3, 2021, 07:18 UTC
- Message-ID
- <CAOLTT8QMpMV=7A4ZP2k5YUrqjznBwh_uDv+qvC7Meq3pwvZt1g@mail.gmail.com>
- In-Reply-To
- <YLfjexczp1/HILWj@coredump.intra.peff.net>
Jeff King <peff@peff.net> 于2021年6月3日周四 上午4:01写道:
Show 7 quoted lines
> > This assumption was broken by 845de33a5b (cat-file: avoid noop calls > to sha1_object_info_extended, 2016-05-18). That commit skips the call > to oid_object_info_extended() entirely when --batch-all-objects is in > use, and the custom format does not include any placeholders that > require calling it. >
Or when the custom format only include placeholders like %(objectname) or %(rest), oid_object_info_extended() will not get the type of the object.
Show 15 quoted lines
> This results in an error when we try to confirm that the type didn't > change: > > $ git cat-file --batch=batman --batch-all-objects > batman > fatal: object 000023961a0c02d6e21dc51ea3484ff71abf1c74 changed type!? > > and also has other subtle effects (e.g., we'd fail to stream a blob, > since we don't realize it's a blog in the first place). > > We can fix this by flipping the order of the setup. The check for "do > we need to get the object info" must come _after_ we've decided > whether we need to look up the type. > > -Peff
-- ZheNing Hu