]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper: inline `reftable_stack_print_directory()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 22 Aug 2024 06:35:12 +0000 (08:35 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 14:59:47 +0000 (07:59 -0700)
Move `reftable_stack_print_directory()` into the "dump-reftable" helper.
This follows the same reasoning as the preceding commit.

Note that this requires us to remove the tests for this functionality in
`reftable/stack_test.c`. The test does not really add much anyway,
because all it verifies is that we do not crash or run into an error,
and it specifically doesn't check the outputted data. Also, as the code
is now part of the test helper, it doesn't make much sense to have a
unit test for it in the first place.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/reftable-stack.h
reftable/stack.c
reftable/stack_test.c
t/helper/test-reftable.c

index 09e97c99915928ed266b7c4bf4ec2b355e86c264..f4f8cabc7fb560ae3dc18882879b4aedc4076d83 100644 (file)
@@ -140,7 +140,4 @@ struct reftable_compaction_stats {
 struct reftable_compaction_stats *
 reftable_stack_compaction_stats(struct reftable_stack *st);
 
-/* print the entire stack represented by the directory */
-int reftable_stack_print_directory(const char *stackdir, uint32_t hash_id);
-
 #endif
index d08ec009590266a492fd50145475168d7d58512e..bedd503e7e1fd26a417fa8fb828b75c9f7bd181b 100644 (file)
@@ -1603,23 +1603,3 @@ done:
        reftable_addition_destroy(add);
        return err;
 }
-
-int reftable_stack_print_directory(const char *stackdir, uint32_t hash_id)
-{
-       struct reftable_stack *stack = NULL;
-       struct reftable_write_options opts = { .hash_id = hash_id };
-       struct reftable_merged_table *merged = NULL;
-       struct reftable_table table = { NULL };
-
-       int err = reftable_new_stack(&stack, stackdir, &opts);
-       if (err < 0)
-               goto done;
-
-       merged = reftable_stack_merged_table(stack);
-       reftable_table_from_merged_table(&table, merged);
-       err = reftable_table_print(&table);
-done:
-       if (stack)
-               reftable_stack_destroy(stack);
-       return err;
-}
index dbca9eaf4a866bb1111fc81ac62e8fa6be4dcf8a..42044ed8a3eb17e75629f65857ab0147222d7df5 100644 (file)
@@ -179,13 +179,6 @@ static void test_reftable_stack_add_one(void)
        EXPECT(0 == strcmp("master", dest.value.symref));
        EXPECT(st->readers_len > 0);
 
-       printf("testing print functionality:\n");
-       err = reftable_stack_print_directory(dir, GIT_SHA1_FORMAT_ID);
-       EXPECT_ERR(err);
-
-       err = reftable_stack_print_directory(dir, GIT_SHA256_FORMAT_ID);
-       EXPECT(err == REFTABLE_FORMAT_ERROR);
-
 #ifndef GIT_WINDOWS_NATIVE
        strbuf_addstr(&scratch, dir);
        strbuf_addstr(&scratch, "/tables.list");
index 19367c25f9a1f76f23508ec7fcd5426fcab11244..db62ea8dc3bbc8b0de60ff06d756b4832e6489db 100644 (file)
@@ -1,6 +1,7 @@
 #include "reftable/system.h"
 #include "reftable/reftable-error.h"
 #include "reftable/reftable-generic.h"
+#include "reftable/reftable-merged.h"
 #include "reftable/reftable-reader.h"
 #include "reftable/reftable-stack.h"
 #include "reftable/reftable-tests.h"
@@ -29,6 +30,26 @@ static void print_help(void)
               "\n");
 }
 
+static int dump_stack(const char *stackdir, uint32_t hash_id)
+{
+       struct reftable_stack *stack = NULL;
+       struct reftable_write_options opts = { .hash_id = hash_id };
+       struct reftable_merged_table *merged = NULL;
+       struct reftable_table table = { NULL };
+
+       int err = reftable_new_stack(&stack, stackdir, &opts);
+       if (err < 0)
+               goto done;
+
+       merged = reftable_stack_merged_table(stack);
+       reftable_table_from_merged_table(&table, merged);
+       err = reftable_table_print(&table);
+done:
+       if (stack)
+               reftable_stack_destroy(stack);
+       return err;
+}
+
 static int dump_reftable(const char *tablename)
 {
        struct reftable_block_source src = { NULL };
@@ -87,7 +108,7 @@ int cmd__dump_reftable(int argc, const char **argv)
        } else if (opt_dump_table) {
                err = dump_reftable(arg);
        } else if (opt_dump_stack) {
-               err = reftable_stack_print_directory(arg, opt_hash_id);
+               err = dump_stack(arg, opt_hash_id);
        }
 
        if (err < 0) {