aboutsummaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 972203f12b..1c93871484 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -3314,7 +3314,7 @@ int bitmap_is_midx(struct bitmap_index *bitmap_git)
return !!bitmap_git->midx;
}
-const struct string_list *bitmap_preferred_tips(struct repository *r)
+static const struct string_list *bitmap_preferred_tips(struct repository *r)
{
const struct string_list *dest;
@@ -3323,6 +3323,33 @@ const struct string_list *bitmap_preferred_tips(struct repository *r)
return NULL;
}
+void for_each_preferred_bitmap_tip(struct repository *repo,
+ each_ref_fn cb, void *cb_data)
+{
+ struct string_list_item *item;
+ const struct string_list *preferred_tips;
+ struct strbuf buf = STRBUF_INIT;
+
+ preferred_tips = bitmap_preferred_tips(repo);
+ if (!preferred_tips)
+ return;
+
+ for_each_string_list_item(item, preferred_tips) {
+ const char *pattern = item->string;
+
+ if (!ends_with(pattern, "/")) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "%s/", pattern);
+ pattern = buf.buf;
+ }
+
+ refs_for_each_ref_in(get_main_ref_store(repo),
+ pattern, cb, cb_data);
+ }
+
+ strbuf_release(&buf);
+}
+
int bitmap_is_preferred_refname(struct repository *r, const char *refname)
{
const struct string_list *preferred_tips = bitmap_preferred_tips(r);