Skip to content

Commit aef8602

Browse files
pks-tgitster
authored andcommitted
reftable/stack: open-code reading refs
To read a reference for the reftable stack, we first create a generic `reftable_table` from the merged table and then read the reference via a convenience function. We are about to remove these generic interfaces, so let's instead open-code the logic to prepare for this removal. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b8ca235 commit aef8602

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

reftable/stack.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,9 +1468,28 @@ reftable_stack_compaction_stats(struct reftable_stack *st)
14681468
int reftable_stack_read_ref(struct reftable_stack *st, const char *refname,
14691469
struct reftable_ref_record *ref)
14701470
{
1471-
struct reftable_table tab = { NULL };
1472-
reftable_table_from_merged_table(&tab, reftable_stack_merged_table(st));
1473-
return reftable_table_read_ref(&tab, refname, ref);
1471+
struct reftable_iterator it = { 0 };
1472+
int ret;
1473+
1474+
reftable_merged_table_init_ref_iterator(st->merged, &it);
1475+
ret = reftable_iterator_seek_ref(&it, refname);
1476+
if (ret)
1477+
goto out;
1478+
1479+
ret = reftable_iterator_next_ref(&it, ref);
1480+
if (ret)
1481+
goto out;
1482+
1483+
if (strcmp(ref->refname, refname) ||
1484+
reftable_ref_record_is_deletion(ref)) {
1485+
reftable_ref_record_release(ref);
1486+
ret = 1;
1487+
goto out;
1488+
}
1489+
1490+
out:
1491+
reftable_iterator_destroy(&it);
1492+
return ret;
14741493
}
14751494

14761495
int reftable_stack_read_log(struct reftable_stack *st, const char *refname,

0 commit comments

Comments
 (0)