Skip to content

Commit 8fa6e9e

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0e9aa9 commit 8fa6e9e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

refs/reftable-backend.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,14 +2412,15 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
24122412
reftable_be_downcast(ref_store, REF_STORE_WRITE, "reflog_expire");
24132413
struct reftable_log_record *logs = NULL;
24142414
struct reftable_log_record *rewritten = NULL;
2415-
struct reftable_ref_record ref_record = {0};
24162415
struct reftable_iterator it = {0};
24172416
struct reftable_addition *add = NULL;
24182417
struct reflog_expiry_arg arg = {0};
24192418
struct reftable_backend *be;
24202419
struct object_id oid = {0};
2420+
struct strbuf referent = STRBUF_INIT;
24212421
uint8_t *last_hash = NULL;
24222422
size_t logs_nr = 0, logs_alloc = 0, i;
2423+
unsigned int type = 0;
24232424
int ret;
24242425

24252426
if (refs->err < 0)
@@ -2441,12 +2442,9 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
24412442
if (ret < 0)
24422443
goto done;
24432444

2444-
ret = reftable_stack_read_ref(be->stack, refname, &ref_record);
2445+
ret = reftable_backend_read_ref(be, refname, &oid, &referent, &type);
24452446
if (ret < 0)
24462447
goto done;
2447-
if (reftable_ref_record_val1(&ref_record))
2448-
oidread(&oid, reftable_ref_record_val1(&ref_record),
2449-
ref_store->repo->hash_algo);
24502448
prepare_fn(refname, &oid, policy_cb_data);
24512449

24522450
while (1) {
@@ -2513,8 +2511,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
25132511
}
25142512
}
25152513

2516-
if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash &&
2517-
reftable_ref_record_val1(&ref_record))
2514+
if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash && !is_null_oid(&oid))
25182515
oidread(&arg.update_oid, last_hash, ref_store->repo->hash_algo);
25192516

25202517
arg.refs = refs;
@@ -2539,11 +2536,11 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
25392536
cleanup_fn(policy_cb_data);
25402537
assert(ret != REFTABLE_API_ERROR);
25412538

2542-
reftable_ref_record_release(&ref_record);
25432539
reftable_iterator_destroy(&it);
25442540
reftable_addition_destroy(add);
25452541
for (i = 0; i < logs_nr; i++)
25462542
reftable_log_record_release(&logs[i]);
2543+
strbuf_release(&referent);
25472544
free(logs);
25482545
free(rewritten);
25492546
return ret;

0 commit comments

Comments
 (0)