Message ID | c474d2eda5b0b4393616109915626134429085d5.1624314293.git.me@ttaylorr.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | multi-pack reachability bitmaps | expand |
On Mon, Jun 21, 2021 at 06:25:29PM -0400, Taylor Blau wrote: > In a recent commit, pack-objects learned support for the > 'pack.preferBitmapTips' configuration. This patch prepares the > multi-pack bitmap code to respect this configuration, too. > > Since the multi-pack bitmap code already does a traversal of all > references (in order to discover the set of reachable commits in the > multi-pack index), it is more efficient to check whether or not each > reference is a suffix of any value of 'pack.preferBitmapTips' rather > than do an additional traversal. > > Implement a function 'bitmap_is_preferred_refname()' which does just > that. The caller will be added in a subsequent patch. I suspect there was some patch reordering here. We don't have any multi-pack bitmap code yet. :) Probably this needs to say something like "in preparation for adding multi-pack bitmap code..." or similar? -Peff
On Wed, Jul 21, 2021 at 06:39:39AM -0400, Jeff King wrote: > On Mon, Jun 21, 2021 at 06:25:29PM -0400, Taylor Blau wrote: > > [...] > > > > Implement a function 'bitmap_is_preferred_refname()' which does just > > that. The caller will be added in a subsequent patch. > > I suspect there was some patch reordering here. We don't have any > multi-pack bitmap code yet. :) > > Probably this needs to say something like "in preparation for adding > multi-pack bitmap code..." or similar? Oops. Good catch! Thanks, Taylor
diff --git a/pack-bitmap.c b/pack-bitmap.c index 9757cd0fbb..d882bf7ce1 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1632,3 +1632,19 @@ const struct string_list *bitmap_preferred_tips(struct repository *r) { return repo_config_get_value_multi(r, "pack.preferbitmaptips"); } + +int bitmap_is_preferred_refname(struct repository *r, const char *refname) +{ + const struct string_list *preferred_tips = bitmap_preferred_tips(r); + struct string_list_item *item; + + if (!preferred_tips) + return 0; + + for_each_string_list_item(item, preferred_tips) { + if (starts_with(refname, item->string)) + return 1; + } + + return 0; +} diff --git a/pack-bitmap.h b/pack-bitmap.h index 020cd8d868..52ea10de51 100644 --- a/pack-bitmap.h +++ b/pack-bitmap.h @@ -94,5 +94,6 @@ void bitmap_writer_finish(struct pack_idx_entry **index, uint16_t options); const struct string_list *bitmap_preferred_tips(struct repository *r); +int bitmap_is_preferred_refname(struct repository *r, const char *refname); #endif
In a recent commit, pack-objects learned support for the 'pack.preferBitmapTips' configuration. This patch prepares the multi-pack bitmap code to respect this configuration, too. Since the multi-pack bitmap code already does a traversal of all references (in order to discover the set of reachable commits in the multi-pack index), it is more efficient to check whether or not each reference is a suffix of any value of 'pack.preferBitmapTips' rather than do an additional traversal. Implement a function 'bitmap_is_preferred_refname()' which does just that. The caller will be added in a subsequent patch. Signed-off-by: Taylor Blau <me@ttaylorr.com> --- pack-bitmap.c | 16 ++++++++++++++++ pack-bitmap.h | 1 + 2 files changed, 17 insertions(+)