aboutsummaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-02-20 10:09:32 -0800
committerJunio C Hamano <gitster@pobox.com>2026-02-20 10:09:32 -0800
commit4fa8cfd68ab9ed6fb273a354ff1b5e240cbabc1d (patch)
tree727bb838a214bbdda297fbe6125b270edc4169c5 /pack-bitmap.c
parent73fd77805fc6406f31c36212846d9e2541d19321 (diff)
parent6375a00ef16071eadbb383bd9915e277ef304bfe (diff)
downloadgit-4fa8cfd68ab9ed6fb273a354ff1b5e240cbabc1d.tar.xz
Merge branch 'ps/for-each-ref-in-fixes' into ps/refs-for-each
* ps/for-each-ref-in-fixes: bisect: simplify string_list memory handling bisect: fix misuse of `refs_for_each_ref_in()` pack-bitmap: fix bug with exact ref match in "pack.preferBitmapTips" pack-bitmap: deduplicate logic to iterate over preferred bitmap tips
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);