@matheusbsbs / matheus-bagliano / commits / ff483026a9
Fork 0

builtin/pack-objects: introduce obj_is_packed()

Let's refactor the way we check if an object is packed by introducing obj_is_packed(). This function is now a simple wrapper around packlist_find(), but it will evolve in a following commit. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 18, 2019 at 12:25 UTC ff483026a9ab29d01b6142ea3b44f4ffd8acb8c2
1 file changed +7 -2
builtin/pack-objects.c
+7 -2
@@ -2569,6 +2569,11 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
2569 free(p);
2570 }
2571
2572 +static int obj_is_packed(const struct object_id *oid)
2573 +{
2574 + return !!packlist_find(&to_pack, oid, NULL);
2575 +}
2576 +
2577 static void add_tag_chain(const struct object_id *oid)
2578 {
2579 struct tag *tag;
@@ -2580,7 +2585,7 @@ static void add_tag_chain(const struct object_id *oid)
2585 * it was included via bitmaps, we would not have parsed it
2586 * previously).
2587 */
2583 - if (packlist_find(&to_pack, oid, NULL))
2588 + if (obj_is_packed(oid))
2589 return;
2590
2591 tag = lookup_tag(the_repository, oid);
@@ -2604,7 +2609,7 @@ static int add_ref_tag(const char *path, const struct object_id *oid, int flag,
2609
2610 if (starts_with(path, "refs/tags/") && /* is a tag? */
2611 !peel_ref(path, &peeled) && /* peelable? */
2607 - packlist_find(&to_pack, &peeled, NULL)) /* object packed? */
2612 + obj_is_packed(&peeled)) /* object packed? */
2613 add_tag_chain(oid);
2614 return 0;
2615 }