refs: convert reflog_expire parameter to struct object_id

reflog_expire already used struct object_id internally, but it did not take it as a parameter. Adjust the parameter (and the callers) to pass a pointer to struct object_id instead of a pointer to unsigned char. Remove the temporary inserted earlier as it is no longer required. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Oct 15, 2017 at 22:07 UTC 0155f710b856970dc1dc5261e740f135c67a7b1d
6 files changed +15 -18
builtin/reflog.c
+3 -3
@@ -589,7 +589,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
589 for (i = 0; i < collected.nr; i++) {
590 struct collected_reflog *e = collected.e[i];
591 set_reflog_expiry_param(&cb.cmd, explicit_expiry, e->reflog);
592 - status |= reflog_expire(e->reflog, e->oid.hash, flags,
592 + status |= reflog_expire(e->reflog, &e->oid, flags,
593 reflog_expiry_prepare,
594 should_expire_reflog_ent,
595 reflog_expiry_cleanup,
@@ -607,7 +607,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
607 continue;
608 }
609 set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref);
610 - status |= reflog_expire(ref, oid.hash, flags,
610 + status |= reflog_expire(ref, &oid, flags,
611 reflog_expiry_prepare,
612 should_expire_reflog_ent,
613 reflog_expiry_cleanup,
@@ -683,7 +683,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
683 cb.cmd.expire_total = 0;
684 }
685
686 - status |= reflog_expire(ref, oid.hash, flags,
686 + status |= reflog_expire(ref, &oid, flags,
687 reflog_expiry_prepare,
688 should_expire_reflog_ent,
689 reflog_expiry_cleanup,
refs.c
+4 -4
@@ -2010,19 +2010,19 @@ int delete_reflog(const char *refname)
2010 }
2011
2012 int refs_reflog_expire(struct ref_store *refs,
2013 - const char *refname, const unsigned char *sha1,
2013 + const char *refname, const struct object_id *oid,
2014 unsigned int flags,
2015 reflog_expiry_prepare_fn prepare_fn,
2016 reflog_expiry_should_prune_fn should_prune_fn,
2017 reflog_expiry_cleanup_fn cleanup_fn,
2018 void *policy_cb_data)
2019 {
2020 - return refs->be->reflog_expire(refs, refname, sha1, flags,
2020 + return refs->be->reflog_expire(refs, refname, oid, flags,
2021 prepare_fn, should_prune_fn,
2022 cleanup_fn, policy_cb_data);
2023 }
2024
2025 -int reflog_expire(const char *refname, const unsigned char *sha1,
2025 +int reflog_expire(const char *refname, const struct object_id *oid,
2026 unsigned int flags,
2027 reflog_expiry_prepare_fn prepare_fn,
2028 reflog_expiry_should_prune_fn should_prune_fn,
@@ -2030,7 +2030,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
2030 void *policy_cb_data)
2031 {
2032 return refs_reflog_expire(get_main_ref_store(),
2033 - refname, sha1, flags,
2033 + refname, oid, flags,
2034 prepare_fn, should_prune_fn,
2035 cleanup_fn, policy_cb_data);
2036 }
refs.h
+3 -3
@@ -703,20 +703,20 @@ typedef int reflog_expiry_should_prune_fn(struct object_id *ooid,
703 typedef void reflog_expiry_cleanup_fn(void *cb_data);
704
705 /*
706 - * Expire reflog entries for the specified reference. sha1 is the old
706 + * Expire reflog entries for the specified reference. oid is the old
707 * value of the reference. flags is a combination of the constants in
708 * enum expire_reflog_flags. The three function pointers are described
709 * above. On success, return zero.
710 */
711 int refs_reflog_expire(struct ref_store *refs,
712 const char *refname,
713 - const unsigned char *sha1,
713 + const struct object_id *oid,
714 unsigned int flags,
715 reflog_expiry_prepare_fn prepare_fn,
716 reflog_expiry_should_prune_fn should_prune_fn,
717 reflog_expiry_cleanup_fn cleanup_fn,
718 void *policy_cb_data);
719 -int reflog_expire(const char *refname, const unsigned char *sha1,
719 +int reflog_expire(const char *refname, const struct object_id *oid,
720 unsigned int flags,
721 reflog_expiry_prepare_fn prepare_fn,
722 reflog_expiry_should_prune_fn should_prune_fn,
refs/files-backend.c
+3 -6
@@ -2908,7 +2908,7 @@ static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
2908 }
2909
2910 static int files_reflog_expire(struct ref_store *ref_store,
2911 - const char *refname, const unsigned char *sha1,
2911 + const char *refname, const struct object_id *oid,
2912 unsigned int flags,
2913 reflog_expiry_prepare_fn prepare_fn,
2914 reflog_expiry_should_prune_fn should_prune_fn,
@@ -2925,7 +2925,6 @@ static int files_reflog_expire(struct ref_store *ref_store,
2925 int status = 0;
2926 int type;
2927 struct strbuf err = STRBUF_INIT;
2928 - struct object_id oid;
2928
2929 memset(&cb, 0, sizeof(cb));
2930 cb.flags = flags;
@@ -2937,7 +2936,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
2936 * reference itself, plus we might need to update the
2937 * reference if --updateref was specified:
2938 */
2940 - lock = lock_ref_sha1_basic(refs, refname, sha1,
2939 + lock = lock_ref_sha1_basic(refs, refname, oid->hash,
2940 NULL, NULL, REF_NODEREF,
2941 &type, &err);
2942 if (!lock) {
@@ -2975,9 +2974,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
2974 }
2975 }
2976
2978 - hashcpy(oid.hash, sha1);
2979 -
2980 - (*prepare_fn)(refname, &oid, cb.policy_cb);
2977 + (*prepare_fn)(refname, oid, cb.policy_cb);
2978 refs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb);
2979 (*cleanup_fn)(cb.policy_cb);
2980
refs/packed-backend.c
+1 -1
@@ -1519,7 +1519,7 @@ static int packed_delete_reflog(struct ref_store *ref_store,
1519 }
1520
1521 static int packed_reflog_expire(struct ref_store *ref_store,
1522 - const char *refname, const unsigned char *sha1,
1522 + const char *refname, const struct object_id *oid,
1523 unsigned int flags,
1524 reflog_expiry_prepare_fn prepare_fn,
1525 reflog_expiry_should_prune_fn should_prune_fn,
refs/refs-internal.h
+1 -1
@@ -608,7 +608,7 @@ typedef int create_reflog_fn(struct ref_store *ref_store, const char *refname,
608 int force_create, struct strbuf *err);
609 typedef int delete_reflog_fn(struct ref_store *ref_store, const char *refname);
610 typedef int reflog_expire_fn(struct ref_store *ref_store,
611 - const char *refname, const unsigned char *sha1,
611 + const char *refname, const struct object_id *oid,
612 unsigned int flags,
613 reflog_expiry_prepare_fn prepare_fn,
614 reflog_expiry_should_prune_fn should_prune_fn,