builtin/reflog: rewrite ref functions 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 5bcad1bce2a2ce20a7d1a24842a2f66be4507b6b
1 file changed +6 -10
builtin/reflog.c
+6 -10
@@ -313,14 +313,14 @@ static int should_expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
313 return 0;
314 }
315
316 -static int push_tip_to_list(const char *refname, const unsigned char *sha1,
316 +static int push_tip_to_list(const char *refname, const struct object_id *oid,
317 int flags, void *cb_data)
318 {
319 struct commit_list **list = cb_data;
320 struct commit *tip_commit;
321 if (flags & REF_ISSYMREF)
322 return 0;
323 - tip_commit = lookup_commit_reference_gently(sha1, 1);
323 + tip_commit = lookup_commit_reference_gently(oid->hash, 1);
324 if (!tip_commit)
325 return 0;
326 commit_list_insert(tip_commit, list);
@@ -352,10 +352,8 @@ static void reflog_expiry_prepare(const char *refname,
352 if (cb->unreachable_expire_kind != UE_ALWAYS) {
353 if (cb->unreachable_expire_kind == UE_HEAD) {
354 struct commit_list *elem;
355 - struct each_ref_fn_sha1_adapter wrapped_push_tip_to_list =
356 - {push_tip_to_list, &cb->tips};
355
358 - for_each_ref(each_ref_fn_adapter, &wrapped_push_tip_to_list);
356 + for_each_ref(push_tip_to_list, &cb->tips);
357 for (elem = cb->tips; elem; elem = elem->next)
358 commit_list_insert(elem->item, &cb->mark_list);
359 } else {
@@ -382,14 +380,14 @@ static void reflog_expiry_cleanup(void *cb_data)
380 }
381 }
382
385 -static int collect_reflog(const char *ref, const unsigned char *sha1, int unused, void *cb_data)
383 +static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data)
384 {
385 struct collected_reflog *e;
386 struct collect_reflog_cb *cb = cb_data;
387 size_t namelen = strlen(ref);
388
389 e = xmalloc(sizeof(*e) + namelen + 1);
392 - hashcpy(e->sha1, sha1);
390 + hashcpy(e->sha1, oid->hash);
391 memcpy(e->reflog, ref, namelen + 1);
392 ALLOC_GROW(cb->e, cb->nr + 1, cb->alloc);
393 cb->e[cb->nr++] = e;
@@ -591,11 +589,9 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
589 if (do_all) {
590 struct collect_reflog_cb collected;
591 int i;
594 - struct each_ref_fn_sha1_adapter wrapped_collect_reflog =
595 - {collect_reflog, &collected};
592
593 memset(&collected, 0, sizeof(collected));
598 - for_each_reflog(each_ref_fn_adapter, &wrapped_collect_reflog);
594 + for_each_reflog(collect_reflog, &collected);
595 for (i = 0; i < collected.nr; i++) {
596 struct collected_reflog *e = collected.e[i];
597 set_reflog_expiry_param(&cb.cmd, explicit_expiry, e->reflog);