Move `reftable_table_print()` into the "dump-reftable" helper. This follows the same reasoning as the preceding commit. Signed-off-by: Patrick Steinhardt <ps@xxxxxx> --- reftable/generic.c | 47 --------------------------------- reftable/reftable-generic.h | 3 --- t/helper/test-reftable.c | 52 +++++++++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 52 deletions(-) diff --git a/reftable/generic.c b/reftable/generic.c index 6ecf9b880f7..495ee9af6b0 100644 --- a/reftable/generic.c +++ b/reftable/generic.c @@ -61,53 +61,6 @@ int reftable_table_read_ref(struct reftable_table *tab, const char *name, return err; } -int reftable_table_print(struct reftable_table *tab) { - struct reftable_iterator it = { NULL }; - struct reftable_ref_record ref = { NULL }; - struct reftable_log_record log = { NULL }; - uint32_t hash_id = reftable_table_hash_id(tab); - int err; - - reftable_table_init_ref_iter(tab, &it); - - err = reftable_iterator_seek_ref(&it, ""); - if (err < 0) - return err; - - while (1) { - err = reftable_iterator_next_ref(&it, &ref); - if (err > 0) { - break; - } - if (err < 0) { - return err; - } - reftable_ref_record_print(&ref, hash_id); - } - reftable_iterator_destroy(&it); - reftable_ref_record_release(&ref); - - reftable_table_init_log_iter(tab, &it); - - err = reftable_iterator_seek_log(&it, ""); - if (err < 0) - return err; - - while (1) { - err = reftable_iterator_next_log(&it, &log); - if (err > 0) { - break; - } - if (err < 0) { - return err; - } - reftable_log_record_print(&log, hash_id); - } - reftable_iterator_destroy(&it); - reftable_log_record_release(&log); - return 0; -} - uint64_t reftable_table_max_update_index(struct reftable_table *tab) { return tab->ops->max_update_index(tab->table_arg); diff --git a/reftable/reftable-generic.h b/reftable/reftable-generic.h index 65670ea093b..b8b1323a331 100644 --- a/reftable/reftable-generic.h +++ b/reftable/reftable-generic.h @@ -41,7 +41,4 @@ uint64_t reftable_table_min_update_index(struct reftable_table *tab); int reftable_table_read_ref(struct reftable_table *tab, const char *name, struct reftable_ref_record *ref); -/* dump table contents onto stdout for debugging */ -int reftable_table_print(struct reftable_table *tab); - #endif diff --git a/t/helper/test-reftable.c b/t/helper/test-reftable.c index db62ea8dc3b..82159fa51f4 100644 --- a/t/helper/test-reftable.c +++ b/t/helper/test-reftable.c @@ -30,6 +30,54 @@ static void print_help(void) "\n"); } +static int dump_table(struct reftable_table *tab) +{ + struct reftable_iterator it = { NULL }; + struct reftable_ref_record ref = { NULL }; + struct reftable_log_record log = { NULL }; + uint32_t hash_id = reftable_table_hash_id(tab); + int err; + + reftable_table_init_ref_iter(tab, &it); + + err = reftable_iterator_seek_ref(&it, ""); + if (err < 0) + return err; + + while (1) { + err = reftable_iterator_next_ref(&it, &ref); + if (err > 0) { + break; + } + if (err < 0) { + return err; + } + reftable_ref_record_print(&ref, hash_id); + } + reftable_iterator_destroy(&it); + reftable_ref_record_release(&ref); + + reftable_table_init_log_iter(tab, &it); + + err = reftable_iterator_seek_log(&it, ""); + if (err < 0) + return err; + + while (1) { + err = reftable_iterator_next_log(&it, &log); + if (err > 0) { + break; + } + if (err < 0) { + return err; + } + reftable_log_record_print(&log, hash_id); + } + reftable_iterator_destroy(&it); + reftable_log_record_release(&log); + return 0; +} + static int dump_stack(const char *stackdir, uint32_t hash_id) { struct reftable_stack *stack = NULL; @@ -43,7 +91,7 @@ static int dump_stack(const char *stackdir, uint32_t hash_id) merged = reftable_stack_merged_table(stack); reftable_table_from_merged_table(&table, merged); - err = reftable_table_print(&table); + err = dump_table(&table); done: if (stack) reftable_stack_destroy(stack); @@ -64,7 +112,7 @@ static int dump_reftable(const char *tablename) goto done; reftable_table_from_reader(&tab, r); - err = reftable_table_print(&tab); + err = dump_table(&tab); done: reftable_reader_free(r); return err; -- 2.46.0.164.g477ce5ccd6.dirty