Re: [PATCH 1/1] builtin/pack-objects.c: avoid iterating all refs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 19, 2021 at 06:08:31PM -0500, Taylor Blau wrote:

> > diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> > index 2a00358f34..2b32bc93bd 100644
> > --- a/builtin/pack-objects.c
> > +++ b/builtin/pack-objects.c
> > @@ -3740,7 +3740,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
> >  	}
> >  	cleanup_preferred_base();
> >  	if (include_tag && nr_result)
> > -		for_each_ref(add_ref_tag, NULL);
> > +		for_each_fullref_in("refs/tags/", add_ref_tag, NULL, 0);
> 
> Makes sense. I was curious why it wasn't this way from the beginning in
> f0a24aa56e (git-pack-objects: Automatically pack annotated tags if
> object was packed, 2008-03-03).
> 
> The patch doesn't say, but presumably it was because there wasn't any
> speed-up to be had iterating only a subset of references back then if
> they were packed (did packed refs even exist in 2008? unsure). In any
> case, builtin/pack-objects.c:add_ref_tag() discards anything that
> doesn't start with "refs/tags/", so I think your change is doing the
> right thing here.
> 
> That said, you could shorten this to use 'for_each_tag_ref()' instead
> (which compiles to the exact same thing).

You'd end up with "v1.2.3" in the refname field of the callback then,
rather than "refs/tags/v1.2.3". So we'd definitely need to drop the
prefix check in add_ref_tag() then (though I think it is a good idea
anyway). But I'm also not sure if it would interfere with peel_ref(),
and its magic for using packed-refs peeled information.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux