git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 10/15] t/helper: inline `reftable_stack_print_directory()`

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 14, 2024, 13:23 UTC
Message-ID
<7acfe4fecc54beaa71d65f04c92e31ebe95aa1a0.1723640107.git.ps@pks.im>
In-Reply-To
<cover.1723640107.git.ps@pks.im>

Move `reftable_stack_print_directory()` into the "dump-reftable" helper. This follows the same reasoning as the preceding commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/reftable-stack.h |  3 ---
 reftable/stack.c          | 20 --------------------
 reftable/stack_test.c     |  7 -------
 t/helper/test-reftable.c  | 23 ++++++++++++++++++++++-
 4 files changed, 22 insertions(+), 31 deletions(-)
diff --git a/reftable/reftable-stack.h b/reftable/reftable-stack.h
index 09e97c9991..f4f8cabc7f 100644
--- a/reftable/reftable-stack.h
+++ b/reftable/reftable-stack.h
@@ -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
diff --git a/reftable/stack.c b/reftable/stack.c
index d08ec00959..bedd503e7e 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -1603,23 +1603,3 @@ int reftable_stack_clean(struct reftable_stack *st)
 	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;
-}
diff --git a/reftable/stack_test.c b/reftable/stack_test.c
index dbca9eaf4a..42044ed8a3 100644
--- a/reftable/stack_test.c
+++ b/reftable/stack_test.c
@@ -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");
diff --git a/t/helper/test-reftable.c b/t/helper/test-reftable.c
index 19367c25f9..db62ea8dc3 100644
--- a/t/helper/test-reftable.c
+++ b/t/helper/test-reftable.c
@@ -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) {
-- 
2.46.0.46.g406f326d27.dirty
Previous: Patrick SteinhardtNext: karthik nayak
Message 11 of 40 in “reftable: drop generic `reftable_table` interface”
  1. 00/15 reftable: drop generic `reftable_table` interfacePatrick Steinhardt, Aug 14, 2024
  2. 01/15 reftable/merged: expose functions to initialize iteratorsPatrick Steinhardt, Aug 14, 2024
  3. 02/15 reftable/merged: rename `reftable_new_merged_table()`Patrick Steinhardt, Aug 14, 2024
  4. 03/15 reftable/merged: stop using generic tables in the merged tablePatrick Steinhardt, Aug 14, 2024
  5. 04/15 reftable/stack: open-code reading refsPatrick Steinhardt, Aug 14, 2024
  6. 05/15 reftable/iter: drop double-checking logicPatrick Steinhardt, Aug 14, 2024
  7. 06/15 reftable/generic: move generic iterator code into iterator interfacePatrick Steinhardt, Aug 14, 2024
  8. 07/15 reftable/dump: drop unused `compact_stack()`Patrick Steinhardt, Aug 14, 2024
  9. 08/15 t/helper: inline `reftable_dump_main()`Patrick Steinhardt, Aug 14, 2024
  10. 09/15 t/helper: inline `reftable_reader_print_file()`Patrick Steinhardt, Aug 14, 2024
  11. 10/15 t/helper: inline `reftable_stack_print_directory()`Patrick Steinhardt, Aug 14, 2024
  12. karthik nayakAug 20, 2024
  13. Patrick SteinhardtAug 20, 2024
  14. 11/15 t/helper: inline `reftable_table_print()`Patrick Steinhardt, Aug 14, 2024
  15. 12/15 t/helper: inline printing of reftable recordsPatrick Steinhardt, Aug 14, 2024
  16. 13/15 t/helper: use `hash_to_hex_algop()` to print hashesPatrick Steinhardt, Aug 14, 2024
  17. 14/15 t/helper: refactor to not use `struct reftable_table`Patrick Steinhardt, Aug 14, 2024
  18. 15/15 reftable/generic: drop interfacePatrick Steinhardt, Aug 14, 2024
  19. Patrick SteinhardtAug 14, 2024
  20. Junio C HamanoAug 14, 2024
  21. Patrick SteinhardtAug 15, 2024
  22. karthik nayakAug 20, 2024
  23. 00/15 reftable: drop generic `reftable_table` interfacePatrick Steinhardt, Aug 22, 2024
  24. 01/15 reftable/merged: expose functions to initialize iteratorsPatrick Steinhardt, Aug 22, 2024
  25. 02/15 reftable/merged: rename `reftable_new_merged_table()`Patrick Steinhardt, Aug 22, 2024
  26. 03/15 reftable/merged: stop using generic tables in the merged tablePatrick Steinhardt, Aug 22, 2024
  27. 04/15 reftable/stack: open-code reading refsPatrick Steinhardt, Aug 22, 2024
  28. 05/15 reftable/iter: drop double-checking logicPatrick Steinhardt, Aug 22, 2024
  29. 06/15 reftable/generic: move generic iterator code into iterator interfacePatrick Steinhardt, Aug 22, 2024
  30. 07/15 reftable/dump: drop unused `compact_stack()`Patrick Steinhardt, Aug 22, 2024
  31. 08/15 t/helper: inline `reftable_dump_main()`Patrick Steinhardt, Aug 22, 2024
  32. 09/15 t/helper: inline `reftable_reader_print_file()`Patrick Steinhardt, Aug 22, 2024
  33. 10/15 t/helper: inline `reftable_stack_print_directory()`Patrick Steinhardt, Aug 22, 2024
  34. 11/15 t/helper: inline `reftable_table_print()`Patrick Steinhardt, Aug 22, 2024
  35. 12/15 t/helper: inline printing of reftable recordsPatrick Steinhardt, Aug 22, 2024
  36. 13/15 t/helper: use `hash_to_hex_algop()` to print hashesPatrick Steinhardt, Aug 22, 2024
  37. 14/15 t/helper: refactor to not use `struct reftable_table`Patrick Steinhardt, Aug 22, 2024
  38. 15/15 reftable/generic: drop interfacePatrick Steinhardt, Aug 22, 2024
  39. karthik nayakAug 22, 2024
  40. Junio C HamanoAug 22, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.