summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-08-22 08:35:15 +0200
committerJunio C Hamano <gitster@pobox.com>2024-08-22 16:59:47 +0200
commit64a5b7a8ca32724699ebfb62f278bae873cc018d (patch)
treef7f5bc03eee191f5dae5b4de8dcdc0d63620908e
parentt/helper: inline `reftable_stack_print_directory()` (diff)
downloadgit-64a5b7a8ca32724699ebfb62f278bae873cc018d.tar.xz
git-64a5b7a8ca32724699ebfb62f278bae873cc018d.zip
t/helper: inline `reftable_table_print()`
Move `reftable_table_print()` into the "dump-reftable" helper. This follows the same reasoning as the preceding commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--reftable/generic.c47
-rw-r--r--reftable/reftable-generic.h3
-rw-r--r--t/helper/test-reftable.c52
3 files changed, 50 insertions, 52 deletions
diff --git a/reftable/generic.c b/reftable/generic.c
index 6ecf9b880f..495ee9af6b 100644
--- a/reftable/generic.c
+++ b/reftable/generic.c
@@ -61,53 +61,6 @@ done:
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 65670ea093..b8b1323a33 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 db62ea8dc3..82159fa51f 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;