refs/reftable: refactor reflog expiry to use reftable backend
Refactor the callback function that expires reflog entries in the reftable backend to use `reftable_backend_read_ref()` instead of accessing the reftable stack directly. This ensures that the function will benefit from the new caching layer that we're about to introduce. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
ad6c41f4b7
commit
96e7cb83b6
@ -2444,14 +2444,15 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
|
|||||||
reftable_be_downcast(ref_store, REF_STORE_WRITE, "reflog_expire");
|
reftable_be_downcast(ref_store, REF_STORE_WRITE, "reflog_expire");
|
||||||
struct reftable_log_record *logs = NULL;
|
struct reftable_log_record *logs = NULL;
|
||||||
struct reftable_log_record *rewritten = NULL;
|
struct reftable_log_record *rewritten = NULL;
|
||||||
struct reftable_ref_record ref_record = {0};
|
|
||||||
struct reftable_iterator it = {0};
|
struct reftable_iterator it = {0};
|
||||||
struct reftable_addition *add = NULL;
|
struct reftable_addition *add = NULL;
|
||||||
struct reflog_expiry_arg arg = {0};
|
struct reflog_expiry_arg arg = {0};
|
||||||
struct reftable_backend *be;
|
struct reftable_backend *be;
|
||||||
struct object_id oid = {0};
|
struct object_id oid = {0};
|
||||||
|
struct strbuf referent = STRBUF_INIT;
|
||||||
uint8_t *last_hash = NULL;
|
uint8_t *last_hash = NULL;
|
||||||
size_t logs_nr = 0, logs_alloc = 0, i;
|
size_t logs_nr = 0, logs_alloc = 0, i;
|
||||||
|
unsigned int type = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (refs->err < 0)
|
if (refs->err < 0)
|
||||||
@ -2473,12 +2474,9 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
ret = reftable_stack_read_ref(be->stack, refname, &ref_record);
|
ret = reftable_backend_read_ref(be, refname, &oid, &referent, &type);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (reftable_ref_record_val1(&ref_record))
|
|
||||||
oidread(&oid, reftable_ref_record_val1(&ref_record),
|
|
||||||
ref_store->repo->hash_algo);
|
|
||||||
prepare_fn(refname, &oid, policy_cb_data);
|
prepare_fn(refname, &oid, policy_cb_data);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -2545,8 +2543,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash &&
|
if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash && !is_null_oid(&oid))
|
||||||
reftable_ref_record_val1(&ref_record))
|
|
||||||
oidread(&arg.update_oid, last_hash, ref_store->repo->hash_algo);
|
oidread(&arg.update_oid, last_hash, ref_store->repo->hash_algo);
|
||||||
|
|
||||||
arg.refs = refs;
|
arg.refs = refs;
|
||||||
@ -2571,11 +2568,11 @@ done:
|
|||||||
cleanup_fn(policy_cb_data);
|
cleanup_fn(policy_cb_data);
|
||||||
assert(ret != REFTABLE_API_ERROR);
|
assert(ret != REFTABLE_API_ERROR);
|
||||||
|
|
||||||
reftable_ref_record_release(&ref_record);
|
|
||||||
reftable_iterator_destroy(&it);
|
reftable_iterator_destroy(&it);
|
||||||
reftable_addition_destroy(add);
|
reftable_addition_destroy(add);
|
||||||
for (i = 0; i < logs_nr; i++)
|
for (i = 0; i < logs_nr; i++)
|
||||||
reftable_log_record_release(&logs[i]);
|
reftable_log_record_release(&logs[i]);
|
||||||
|
strbuf_release(&referent);
|
||||||
free(logs);
|
free(logs);
|
||||||
free(rewritten);
|
free(rewritten);
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user