pack-bitmap.c: introduce 'bitmap_is_preferred_refname()'
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. The yet-to-be implemented code will find that it is more efficient to check whether each reference contains a prefix found in the configured set of values rather than doing an additional traversal. Implement a function 'bitmap_is_preferred_refname()' which will perform that check. Its caller will be added in a subsequent patch. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Aug 31, 2021 at 16:52 UTC
711260fd60366063e8c5253a83fc4aeb8947dc9d
2 files changed
+17
pack-bitmap.c
+16
@@ -1658,3 +1658,19 @@ const struct string_list *bitmap_preferred_tips(struct repository *r)
1658
{
1659
return repo_config_get_value_multi(r, "pack.preferbitmaptips");
1660
}
1661
+
1662
+int bitmap_is_preferred_refname(struct repository *r, const char *refname)
1663
+{
1664
+ const struct string_list *preferred_tips = bitmap_preferred_tips(r);
1665
+ struct string_list_item *item;
1666
+
1667
+ if (!preferred_tips)
1668
+ return 0;
1669
+
1670
+ for_each_string_list_item(item, preferred_tips) {
1671
+ if (starts_with(refname, item->string))
1672
+ return 1;
1673
+ }
1674
+
1675
+ return 0;
1676
+}
pack-bitmap.h
+1
@@ -94,5 +94,6 @@ void bitmap_writer_finish(struct pack_idx_entry **index,
94
uint16_t options);
95
96
const struct string_list *bitmap_preferred_tips(struct repository *r);
97
+int bitmap_is_preferred_refname(struct repository *r, const char *refname);
98
99
#endif