builtin/pack-objects: rewrite to take an object_id argument
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
May 25, 2015 at 18:38 UTC
d155254c73cfa5cbd82e8ad97840e4c9dbf762b0
1 file changed
+10
-16
builtin/pack-objects.c
+10
-16
@@ -540,11 +540,11 @@ static enum write_one_status write_one(struct sha1file *f,
540
return WRITE_ONE_WRITTEN;
541
}
542
543
-static int mark_tagged(const char *path, const unsigned char *sha1, int flag,
543
+static int mark_tagged(const char *path, const struct object_id *oid, int flag,
544
void *cb_data)
545
{
546
unsigned char peeled[20];
547
- struct object_entry *entry = packlist_find(&to_pack, sha1, NULL);
547
+ struct object_entry *entry = packlist_find(&to_pack, oid->hash, NULL);
548
549
if (entry)
550
entry->tagged = 1;
@@ -626,8 +626,6 @@ static struct object_entry **compute_write_order(void)
626
627
struct object_entry **wo = xmalloc(to_pack.nr_objects * sizeof(*wo));
628
struct object_entry *objects = to_pack.objects;
629
- struct each_ref_fn_sha1_adapter wrapped_mark_tagged =
630
- {mark_tagged, NULL};
629
630
for (i = 0; i < to_pack.nr_objects; i++) {
631
objects[i].tagged = 0;
@@ -653,7 +651,7 @@ static struct object_entry **compute_write_order(void)
651
/*
652
* Mark objects that are at the tip of tags.
653
*/
656
- for_each_tag_ref(each_ref_fn_adapter, &wrapped_mark_tagged);
654
+ for_each_tag_ref(mark_tagged, NULL);
655
656
/*
657
* Give the objects in the original recency order until
@@ -2099,14 +2097,14 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
2097
#define ll_find_deltas(l, s, w, d, p) find_deltas(l, &s, w, d, p)
2098
#endif
2099
2102
-static int add_ref_tag(const char *path, const unsigned char *sha1, int flag, void *cb_data)
2100
+static int add_ref_tag(const char *path, const struct object_id *oid, int flag, void *cb_data)
2101
{
2104
- unsigned char peeled[20];
2102
+ struct object_id peeled;
2103
2104
if (starts_with(path, "refs/tags/") && /* is a tag? */
2107
- !peel_ref(path, peeled) && /* peelable? */
2108
- packlist_find(&to_pack, peeled, NULL)) /* object packed? */
2109
- add_object_entry(sha1, OBJ_TAG, NULL, 0);
2105
+ !peel_ref(path, peeled.hash) && /* peelable? */
2106
+ packlist_find(&to_pack, peeled.hash, NULL)) /* object packed? */
2107
+ add_object_entry(oid->hash, OBJ_TAG, NULL, 0);
2108
return 0;
2109
}
2110
@@ -2786,12 +2784,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
2784
argv_array_clear(&rp);
2785
}
2786
cleanup_preferred_base();
2789
- if (include_tag && nr_result) {
2790
- struct each_ref_fn_sha1_adapter wrapped_add_ref_tag =
2791
- {add_ref_tag, NULL};
2792
-
2793
- for_each_ref(each_ref_fn_adapter, &wrapped_add_ref_tag);
2794
- }
2787
+ if (include_tag && nr_result)
2788
+ for_each_ref(add_ref_tag, NULL);
2789
stop_progress(&progress_state);
2790
2791
if (non_empty && !nr_result)