From: Jeff King Date: Tue, 10 Oct 2017 12:36:34 GMT Subject: Re: [PATCH v4 4/4] sha1_name: minimize OID comparisons during disambiguation Message-ID: <20171010123634.3hdqxpo6mbl6jhbx@sigill.intra.peff.net> In-Reply-To: <338aab6a-1181-d740-1bf2-2ac86749a6b2@gmail.com> On Tue, Oct 10, 2017 at 08:16:27AM -0400, Derrick Stolee wrote: > > > + mad->init_len = 0; > > > + if (!match) { > > > + nth_packed_object_oid(&oid, p, first); > > > + extend_abbrev_len(&oid, mad); > > If we have zero objects in the pack, what would nth_packed_object_oid() > > be returning here? > > > > So I actually think we do want an early return, not just when > > open_packed_index() fails, but also when p->num_objects is zero. > > > > -Peff > > Sorry about this. I caught this while I was writing my cover letter and > amended my last commit to include the following: > >     if (open_pack_index(p)) >         return; > > After I amended the commit, I forgot to 'format-patch' again. I can send a > diff between the commits after review has calmed. OK, I think that makes more sense. But note the p->num_objects thing I mentioned. If I do: git pack-objects .git/objects/pack/pack num_objects) return; Technically that also covers open_pack_index() failure, too, but that's a subtlety I don't think we should rely on. -Peff