From: Junio C Hamano Date: Thu, 13 Feb 2020 18:10:45 GMT Subject: Re: [PATCH 2/5] object.c: lookup_unknown_object() accept 'r' as parameter Message-ID: In-Reply-To: <20200213180030.GF45518@syl.local> Taylor Blau writes: > On Wed, Feb 12, 2020 at 01:11:02PM -0800, Junio C Hamano wrote: >> Taylor Blau 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.