git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: karthik nayak <karthik.188@gmail.com>,
	Justin Tobler <jltobler@gmail.com>
Subject: [PATCH v3 11/15] t/helper: inline `reftable_table_print()`
Date: Thu, 22 Aug 2024 08:35:15 +0200	[thread overview]
Message-ID: <a05e20609962676a2b5f0cd8ce678c2c86c84114.1724308389.git.ps@pks.im> (raw)
In-Reply-To: <cover.1724308389.git.ps@pks.im>

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>
---
 reftable/generic.c          | 47 ---------------------------------
 reftable/reftable-generic.h |  3 ---
 t/helper/test-reftable.c    | 52 +++++++++++++++++++++++++++++++++++--
 3 files changed, 50 insertions(+), 52 deletions(-)

diff --git a/reftable/generic.c b/reftable/generic.c
index 6ecf9b880f7..495ee9af6b0 100644
--- a/reftable/generic.c
+++ b/reftable/generic.c
@@ -61,53 +61,6 @@ int reftable_table_read_ref(struct reftable_table *tab, const char *name,
 	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 65670ea093b..b8b1323a331 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 db62ea8dc3b..82159fa51f4 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;
-- 
2.46.0.164.g477ce5ccd6.dirty


  parent reply	other threads:[~2024-08-22  6:35 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 13:22 [PATCH v2 00/15] reftable: drop generic `reftable_table` interface Patrick Steinhardt
2024-08-14 13:22 ` [PATCH v2 01/15] reftable/merged: expose functions to initialize iterators Patrick Steinhardt
2024-08-14 13:22 ` [PATCH v2 02/15] reftable/merged: rename `reftable_new_merged_table()` Patrick Steinhardt
2024-08-14 13:22 ` [PATCH v2 03/15] reftable/merged: stop using generic tables in the merged table Patrick Steinhardt
2024-08-14 13:22 ` [PATCH v2 04/15] reftable/stack: open-code reading refs Patrick Steinhardt
2024-08-14 13:22 ` [PATCH v2 05/15] reftable/iter: drop double-checking logic Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 06/15] reftable/generic: move generic iterator code into iterator interface Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 07/15] reftable/dump: drop unused `compact_stack()` Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 08/15] t/helper: inline `reftable_dump_main()` Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 09/15] t/helper: inline `reftable_reader_print_file()` Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 10/15] t/helper: inline `reftable_stack_print_directory()` Patrick Steinhardt
2024-08-20  7:34   ` karthik nayak
2024-08-20  8:06     ` Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 11/15] t/helper: inline `reftable_table_print()` Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 12/15] t/helper: inline printing of reftable records Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 13/15] t/helper: use `hash_to_hex_algop()` to print hashes Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 14/15] t/helper: refactor to not use `struct reftable_table` Patrick Steinhardt
2024-08-14 13:23 ` [PATCH v2 15/15] reftable/generic: drop interface Patrick Steinhardt
2024-08-14 13:31 ` [PATCH v2 00/15] reftable: drop generic `reftable_table` interface Patrick Steinhardt
2024-08-14 17:21   ` Junio C Hamano
2024-08-15  5:29     ` Patrick Steinhardt
2024-08-20  7:38 ` karthik nayak
2024-08-22  6:34 ` [PATCH v3 " Patrick Steinhardt
2024-08-22  6:34   ` [PATCH v3 01/15] reftable/merged: expose functions to initialize iterators Patrick Steinhardt
2024-08-22  6:34   ` [PATCH v3 02/15] reftable/merged: rename `reftable_new_merged_table()` Patrick Steinhardt
2024-08-22  6:34   ` [PATCH v3 03/15] reftable/merged: stop using generic tables in the merged table Patrick Steinhardt
2024-08-22  6:34   ` [PATCH v3 04/15] reftable/stack: open-code reading refs Patrick Steinhardt
2024-08-22  6:34   ` [PATCH v3 05/15] reftable/iter: drop double-checking logic Patrick Steinhardt
2024-08-22  6:34   ` [PATCH v3 06/15] reftable/generic: move generic iterator code into iterator interface Patrick Steinhardt
2024-08-22  6:35   ` [PATCH v3 07/15] reftable/dump: drop unused `compact_stack()` Patrick Steinhardt
2024-08-22  6:35   ` [PATCH v3 08/15] t/helper: inline `reftable_dump_main()` Patrick Steinhardt
2024-08-22  6:35   ` [PATCH v3 09/15] t/helper: inline `reftable_reader_print_file()` Patrick Steinhardt
2024-08-22  6:35   ` [PATCH v3 10/15] t/helper: inline `reftable_stack_print_directory()` Patrick Steinhardt
2024-08-22  6:35   ` Patrick Steinhardt [this message]
2024-08-22  6:35   ` [PATCH v3 12/15] t/helper: inline printing of reftable records Patrick Steinhardt
2024-08-22  6:35   ` [PATCH v3 13/15] t/helper: use `hash_to_hex_algop()` to print hashes Patrick Steinhardt
2024-08-22  6:35   ` [PATCH v3 14/15] t/helper: refactor to not use `struct reftable_table` Patrick Steinhardt
2024-08-22  6:35   ` [PATCH v3 15/15] reftable/generic: drop interface Patrick Steinhardt
2024-08-22  8:03   ` [PATCH v3 00/15] reftable: drop generic `reftable_table` interface karthik nayak
2024-08-22 17:11   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a05e20609962676a2b5f0cd8ce678c2c86c84114.1724308389.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=jltobler@gmail.com \
    --cc=karthik.188@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).