Re: [PATCH 2/5] object.c: lookup_unknown_object() accept 'r' as parameter
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 13, 2020, 18:10 UTC
- Message-ID
- <xmqqh7zus6hm.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20200213180030.GF45518@syl.local>
Taylor Blau <me@ttaylorr.com> writes:
Show 24 quoted lines
> On Wed, Feb 12, 2020 at 01:11:02PM -0800, Junio C Hamano wrote:
>> Taylor Blau <me@ttaylorr.com> writes:
>>
>> > ... same question about why assigning:
>> >
>> > struct repository *r = the_repository;
>> >
>> > and passing 'r' everywhere is preferable to simply passing
>> > 'the_repository' in directly.
>> > ...
>> >> static void mark_object_for_connectivity(const struct object_id *oid)
>> >> {
>> >> - struct object *obj = lookup_unknown_object(oid);
>> >> + struct repository *r = the_repository;
>> >> + struct object *obj = lookup_unknown_object(r, oid);
>> >> obj->flags |= HAS_OBJ;
>> >> }
>> ...
> Right, but my suggestion was that this advice doesn't apply to this
> particular instance since I don't expect that we'd ever passing
> something other than 'the_repository'.
>
> Specifically, I was worried that we'd get bitten by re-assigning 'r' in
> the middle of the function and then end up in some odd broken state."git fsck" works only in a single, "the", repository, so I guess you are right to be worried about unnecessary complexity here.