@@ -2409,6 +2409,7 @@ REFTABLE_OBJS += reftable/zlib-compat.o
REFTABLE_TEST_OBJS += reftable/basics_test.o
REFTABLE_TEST_OBJS += reftable/block_test.o
+REFTABLE_TEST_OBJS += reftable/dump.o
REFTABLE_TEST_OBJS += reftable/merged_test.o
REFTABLE_TEST_OBJS += reftable/record_test.o
REFTABLE_TEST_OBJS += reftable/refname_test.o
@@ -12,18 +12,25 @@ license that can be found in the LICENSE file or at
#include <unistd.h>
#include <string.h>
-#include "reftable.h"
+#include "reftable-blocksource.h"
+#include "reftable-error.h"
+#include "reftable-merged.h"
+#include "reftable-record.h"
#include "reftable-tests.h"
+#include "reftable-writer.h"
+#include "reftable-iterator.h"
+#include "reftable-reader.h"
+#include "reftable-stack.h"
static uint32_t hash_id;
static int dump_table(const char *tablename)
{
- struct reftable_block_source src = { 0 };
+ struct reftable_block_source src = { NULL };
int err = reftable_block_source_from_file(&src, tablename);
- struct reftable_iterator it = { 0 };
- struct reftable_ref_record ref = { 0 };
- struct reftable_log_record log = { 0 };
+ struct reftable_iterator it = { NULL };
+ struct reftable_ref_record ref = { NULL };
+ struct reftable_log_record log = { NULL };
struct reftable_reader *r = NULL;
if (err < 0)
@@ -49,7 +56,7 @@ static int dump_table(const char *tablename)
reftable_ref_record_print(&ref, hash_id);
}
reftable_iterator_destroy(&it);
- reftable_ref_record_clear(&ref);
+ reftable_ref_record_release(&ref);
err = reftable_reader_seek_log(r, &it, "");
if (err < 0) {
@@ -66,7 +73,7 @@ static int dump_table(const char *tablename)
reftable_log_record_print(&log, hash_id);
}
reftable_iterator_destroy(&it);
- reftable_log_record_clear(&log);
+ reftable_log_record_release(&log);
reftable_reader_free(r);
return 0;
@@ -95,9 +102,9 @@ static int dump_stack(const char *stackdir)
{
struct reftable_stack *stack = NULL;
struct reftable_write_options cfg = {};
- struct reftable_iterator it = { 0 };
- struct reftable_ref_record ref = { 0 };
- struct reftable_log_record log = { 0 };
+ struct reftable_iterator it = { NULL };
+ struct reftable_ref_record ref = { NULL };
+ struct reftable_log_record log = { NULL };
struct reftable_merged_table *merged = NULL;
int err = reftable_new_stack(&stack, stackdir, cfg);
@@ -122,7 +129,7 @@ static int dump_stack(const char *stackdir)
reftable_ref_record_print(&ref, hash_id);
}
reftable_iterator_destroy(&it);
- reftable_ref_record_clear(&ref);
+ reftable_ref_record_release(&ref);
err = reftable_merged_table_seek_log(merged, &it, "");
if (err < 0) {
@@ -139,7 +146,7 @@ static int dump_stack(const char *stackdir)
reftable_log_record_print(&log, hash_id);
}
reftable_iterator_destroy(&it);
- reftable_log_record_clear(&log);
+ reftable_log_record_release(&log);
reftable_stack_destroy(stack);
return 0;
@@ -13,3 +13,8 @@ int cmd__reftable(int argc, const char **argv)
tree_test_main(argc, argv);
return 0;
}
+
+int cmd__dump_reftable(int argc, const char **argv)
+{
+ return reftable_dump_main(argc, (char *const *)argv);
+}
@@ -56,6 +56,7 @@ static struct test_cmd cmds[] = {
{ "read-midx", cmd__read_midx },
{ "ref-store", cmd__ref_store },
{ "reftable", cmd__reftable },
+ { "dump-reftable", cmd__dump_reftable },
{ "regex", cmd__regex },
{ "repository", cmd__repository },
{ "revision-walking", cmd__revision_walking },
@@ -18,6 +18,7 @@ int cmd__dump_cache_tree(int argc, const char **argv);
int cmd__dump_fsmonitor(int argc, const char **argv);
int cmd__dump_split_index(int argc, const char **argv);
int cmd__dump_untracked_cache(int argc, const char **argv);
+int cmd__dump_reftable(int argc, const char **argv);
int cmd__example_decorate(int argc, const char **argv);
int cmd__fast_rebase(int argc, const char **argv);
int cmd__genrandom(int argc, const char **argv);