@@ -798,27 +798,6 @@ void reftable_table_from_reader(struct reftable_table *tab,
tab->table_arg = reader;
}
-
-int reftable_reader_print_file(const char *tablename)
-{
- struct reftable_block_source src = { NULL };
- int err = reftable_block_source_from_file(&src, tablename);
- struct reftable_reader *r = NULL;
- struct reftable_table tab = { NULL };
- if (err < 0)
- goto done;
-
- err = reftable_new_reader(&r, &src, tablename);
- if (err < 0)
- goto done;
-
- reftable_table_from_reader(&tab, r);
- err = reftable_table_print(&tab);
-done:
- reftable_reader_free(r);
- return err;
-}
-
int reftable_reader_print_blocks(const char *tablename)
{
struct {
@@ -64,8 +64,6 @@ uint64_t reftable_reader_min_update_index(struct reftable_reader *r);
void reftable_table_from_reader(struct reftable_table *tab,
struct reftable_reader *reader);
-/* print table onto stdout for debugging. */
-int reftable_reader_print_file(const char *tablename);
/* print blocks onto stdout for debugging. */
int reftable_reader_print_blocks(const char *tablename);
@@ -1,5 +1,6 @@
#include "reftable/system.h"
#include "reftable/reftable-error.h"
+#include "reftable/reftable-generic.h"
#include "reftable/reftable-reader.h"
#include "reftable/reftable-stack.h"
#include "reftable/reftable-tests.h"
@@ -28,6 +29,26 @@ static void print_help(void)
"\n");
}
+static int dump_reftable(const char *tablename)
+{
+ struct reftable_block_source src = { NULL };
+ int err = reftable_block_source_from_file(&src, tablename);
+ struct reftable_reader *r = NULL;
+ struct reftable_table tab = { NULL };
+ if (err < 0)
+ goto done;
+
+ err = reftable_new_reader(&r, &src, tablename);
+ if (err < 0)
+ goto done;
+
+ reftable_table_from_reader(&tab, r);
+ err = reftable_table_print(&tab);
+done:
+ reftable_reader_free(r);
+ return err;
+}
+
int cmd__dump_reftable(int argc, const char **argv)
{
int err = 0;
@@ -64,7 +85,7 @@ int cmd__dump_reftable(int argc, const char **argv)
if (opt_dump_blocks) {
err = reftable_reader_print_blocks(arg);
} else if (opt_dump_table) {
- err = reftable_reader_print_file(arg);
+ err = dump_reftable(arg);
} else if (opt_dump_stack) {
err = reftable_stack_print_directory(arg, opt_hash_id);
}
Move `reftable_reader_print_file()` into the "dump-reftable" helper. This follows the same reasoning as the preceding commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> --- reftable/reader.c | 21 --------------------- reftable/reftable-reader.h | 2 -- t/helper/test-reftable.c | 23 ++++++++++++++++++++++- 3 files changed, 22 insertions(+), 24 deletions(-)