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 </dev/null
then I have a pack with zero objects, which I think we'd similarly want
to return early from. I.e., I think we need:
if (p->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