From: "Eslam reda ragheb via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Phillip Wood <phillip.wood123@gmail.com>,
eslam reda <eslam.reda.div@gmail.com>,
Eslam reda ragheb <eslam.reda.div@gmail.com>
Subject: [PATCH v5 10/11] repo: reduce repetition in structure keyvalue output
Date: Fri, 27 Feb 2026 19:30:39 +0000 [thread overview]
Message-ID: <1bc100d6cab3b77badb5d79fb8133e22a35bd96e.1772220640.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2208.v5.git.git.1772220640.gitgitgadget@gmail.com>
From: Eslam reda ragheb <eslam.reda.div@gmail.com>
Refactor structure_keyvalue_print() to use small helpers for
single-key and per-object-type metrics.
This makes the output section easier to review and reduces
copy/paste risk while keeping output keys unchanged.
Signed-off-by: Eslam reda ragheb <eslam.reda.div@gmail.com>
---
builtin/repo.c | 156 ++++++++++++++++++++++++-------------------------
1 file changed, 76 insertions(+), 80 deletions(-)
diff --git a/builtin/repo.c b/builtin/repo.c
index cb70171412..ecd9d3aee5 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -821,6 +821,27 @@ static void stats_table_clear(struct stats_table *table)
string_list_clear(&table->rows, 1);
}
+static void print_keyvalue_size(const char *key, size_t value,
+ char key_delim, char value_delim)
+{
+ printf("%s%c%" PRIuMAX "%c", key, key_delim, (uintmax_t)value,
+ value_delim);
+}
+
+static void print_object_values(const struct object_values *values,
+ const char *metric,
+ char key_delim, char value_delim)
+{
+ printf("objects.commits.%s%c%" PRIuMAX "%c", metric, key_delim,
+ (uintmax_t)values->commits, value_delim);
+ printf("objects.trees.%s%c%" PRIuMAX "%c", metric, key_delim,
+ (uintmax_t)values->trees, value_delim);
+ printf("objects.blobs.%s%c%" PRIuMAX "%c", metric, key_delim,
+ (uintmax_t)values->blobs, value_delim);
+ printf("objects.tags.%s%c%" PRIuMAX "%c", metric, key_delim,
+ (uintmax_t)values->tags, value_delim);
+}
+
static void structure_keyvalue_print(struct repo_structure *stats,
char key_delim, char value_delim)
{
@@ -831,86 +852,61 @@ static void structure_keyvalue_print(struct repo_structure *stats,
size_t max_inflated_size = get_max_object_value(&stats->objects.max_inflated_sizes);
size_t max_disk_size = get_max_object_value(&stats->objects.max_disk_sizes);
- printf("references.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)references_count_total, value_delim);
-
- printf("references.branches.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->refs.branches, value_delim);
- printf("references.tags.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->refs.tags, value_delim);
- printf("references.remotes.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->refs.remotes, value_delim);
- printf("references.others.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->refs.others, value_delim);
-
- printf("objects.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)object_count_total, value_delim);
-
- printf("objects.commits.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.type_counts.commits, value_delim);
- printf("objects.trees.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.type_counts.trees, value_delim);
- printf("objects.blobs.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.type_counts.blobs, value_delim);
- printf("objects.tags.count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.type_counts.tags, value_delim);
-
- printf("objects.inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)inflated_size_total, value_delim);
-
- printf("objects.commits.inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.inflated_sizes.commits, value_delim);
- printf("objects.trees.inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.inflated_sizes.trees, value_delim);
- printf("objects.blobs.inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.inflated_sizes.blobs, value_delim);
- printf("objects.tags.inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.inflated_sizes.tags, value_delim);
-
- printf("objects.max_inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)max_inflated_size, value_delim);
- printf("objects.commits.max_inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_inflated_sizes.commits, value_delim);
- printf("objects.trees.max_inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_inflated_sizes.trees, value_delim);
- printf("objects.blobs.max_inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_inflated_sizes.blobs, value_delim);
- printf("objects.tags.max_inflated_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_inflated_sizes.tags, value_delim);
-
- printf("objects.disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)disk_size_total, value_delim);
-
- printf("objects.max_disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)max_disk_size, value_delim);
- printf("objects.commits.max_disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_disk_sizes.commits, value_delim);
- printf("objects.trees.max_disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_disk_sizes.trees, value_delim);
- printf("objects.blobs.max_disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_disk_sizes.blobs, value_delim);
- printf("objects.tags.max_disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_disk_sizes.tags, value_delim);
-
- printf("objects.commits.max_parent_count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_commit_parent_count, value_delim);
- printf("objects.trees.max_entry_count%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_tree_entry_count, value_delim);
- printf("objects.blobs.max_path_length%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_blob_path_length, value_delim);
- printf("objects.blobs.max_path_depth%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_blob_path_depth, value_delim);
- printf("objects.tags.max_chain_depth%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.max_tag_chain_depth, value_delim);
-
- printf("objects.commits.disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.disk_sizes.commits, value_delim);
- printf("objects.trees.disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.disk_sizes.trees, value_delim);
- printf("objects.blobs.disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.disk_sizes.blobs, value_delim);
- printf("objects.tags.disk_size%c%" PRIuMAX "%c", key_delim,
- (uintmax_t)stats->objects.disk_sizes.tags, value_delim);
+ print_keyvalue_size("references.count", references_count_total,
+ key_delim, value_delim);
+
+ print_keyvalue_size("references.branches.count", stats->refs.branches,
+ key_delim, value_delim);
+ print_keyvalue_size("references.tags.count", stats->refs.tags,
+ key_delim, value_delim);
+ print_keyvalue_size("references.remotes.count", stats->refs.remotes,
+ key_delim, value_delim);
+ print_keyvalue_size("references.others.count", stats->refs.others,
+ key_delim, value_delim);
+
+ print_keyvalue_size("objects.count", object_count_total,
+ key_delim, value_delim);
+
+ print_object_values(&stats->objects.type_counts, "count",
+ key_delim, value_delim);
+
+ print_keyvalue_size("objects.inflated_size", inflated_size_total,
+ key_delim, value_delim);
+
+ print_object_values(&stats->objects.inflated_sizes, "inflated_size",
+ key_delim, value_delim);
+
+ print_keyvalue_size("objects.max_inflated_size", max_inflated_size,
+ key_delim, value_delim);
+ print_object_values(&stats->objects.max_inflated_sizes,
+ "max_inflated_size", key_delim, value_delim);
+
+ print_keyvalue_size("objects.disk_size", disk_size_total,
+ key_delim, value_delim);
+
+ print_keyvalue_size("objects.max_disk_size", max_disk_size,
+ key_delim, value_delim);
+ print_object_values(&stats->objects.max_disk_sizes, "max_disk_size",
+ key_delim, value_delim);
+
+ print_keyvalue_size("objects.commits.max_parent_count",
+ stats->objects.max_commit_parent_count,
+ key_delim, value_delim);
+ print_keyvalue_size("objects.trees.max_entry_count",
+ stats->objects.max_tree_entry_count,
+ key_delim, value_delim);
+ print_keyvalue_size("objects.blobs.max_path_length",
+ stats->objects.max_blob_path_length,
+ key_delim, value_delim);
+ print_keyvalue_size("objects.blobs.max_path_depth",
+ stats->objects.max_blob_path_depth,
+ key_delim, value_delim);
+ print_keyvalue_size("objects.tags.max_chain_depth",
+ stats->objects.max_tag_chain_depth,
+ key_delim, value_delim);
+
+ print_object_values(&stats->objects.disk_sizes, "disk_size",
+ key_delim, value_delim);
fflush(stdout);
}
--
gitgitgadget
next prev parent reply other threads:[~2026-02-27 19:30 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-22 18:28 [PATCH 0/3] repo: extend info path reporting and structure statistics eslam reda via GitGitGadget
2026-02-22 18:28 ` [PATCH 1/3] repo: extend info paths " eslam-reda-div via GitGitGadget
2026-02-22 20:35 ` Lucas Seiki Oshiro
2026-02-23 3:02 ` Justin Tobler
2026-02-22 18:28 ` [PATCH 2/3] t1900,t1901: make repo tests hash-agnostic and wc-portable Eslam reda ragheb via GitGitGadget
2026-02-22 20:46 ` Lucas Seiki Oshiro
2026-02-22 18:28 ` [PATCH 3/3] t1900,t1901: fix test portability issues Eslam reda ragheb via GitGitGadget
2026-02-22 22:37 ` [PATCH 0/3] repo: extend info path reporting and structure statistics Junio C Hamano
2026-02-23 14:21 ` [PATCH v2 0/9] " eslam reda via GitGitGadget
2026-02-23 14:21 ` [PATCH v2 1/9] repo: teach info context and category keys Eslam reda ragheb via GitGitGadget
2026-02-23 14:21 ` [PATCH v2 2/9] repo: add path keys to repo info Eslam reda ragheb via GitGitGadget
2026-02-23 14:21 ` [PATCH v2 4/9] repo: add structure max object size metrics Eslam reda ragheb via GitGitGadget
2026-02-23 14:21 ` [PATCH v2 5/9] repo: add structure topology and path-depth metrics Eslam reda ragheb via GitGitGadget
2026-02-23 14:21 ` [PATCH v2 6/9] repo: add aggregate structure totals to keyvalue output Eslam reda ragheb via GitGitGadget
2026-02-23 14:21 ` [PATCH v2 7/9] t1900: cover repo info path keys and path-format Eslam reda ragheb via GitGitGadget
2026-02-23 14:21 ` [PATCH v2 8/9] t1901: extend structure metric coverage and portability Eslam reda ragheb via GitGitGadget
2026-02-23 14:21 ` [PATCH v2 9/9] docs: describe repo info path keys and structure metrics Eslam reda ragheb via GitGitGadget
2026-02-23 19:43 ` [PATCH v3 0/5] repo: extend info path reporting and structure statistics eslam reda via GitGitGadget
2026-02-23 19:43 ` [PATCH v3 1/5] repo: teach info context and category keys Eslam reda ragheb via GitGitGadget
2026-02-23 19:43 ` [PATCH v3 2/5] repo: add path keys to repo info Eslam reda ragheb via GitGitGadget
2026-02-23 19:43 ` [PATCH v3 3/5] repo: add --path-format for info path output Eslam reda ragheb via GitGitGadget
2026-02-23 19:43 ` [PATCH v3 4/5] t1900: cover repo info path keys and path-format Eslam reda ragheb via GitGitGadget
2026-02-23 19:43 ` [PATCH v3 5/5] docs: describe repo info path keys Eslam reda ragheb via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 00/10] repo info: add category/path keys and --path-format eslam reda via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 01/10] repo: teach info context and category keys Eslam reda ragheb via GitGitGadget
2026-02-26 23:21 ` Junio C Hamano
2026-02-26 21:14 ` [PATCH v4 02/10] repo: add path keys to repo info Eslam reda ragheb via GitGitGadget
2026-02-26 23:29 ` Junio C Hamano
2026-02-27 9:04 ` Phillip Wood
2026-02-27 19:51 ` Junio C Hamano
2026-03-01 10:36 ` Phillip Wood
2026-03-02 6:42 ` Junio C Hamano
2026-02-26 21:14 ` [PATCH v4 03/10] repo: add --path-format for info path output Eslam reda ragheb via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 04/10] repo: add structure max object size metrics Eslam reda ragheb via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 05/10] repo: add structure topology and path-depth metrics Eslam reda ragheb via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 06/10] repo: add aggregate structure totals to keyvalue output Eslam reda ragheb via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 07/10] t1900: cover repo info path keys and path-format Eslam reda ragheb via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 08/10] t1901: extend structure metric coverage and portability Eslam reda ragheb via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 09/10] docs: describe repo info path keys and structure metrics Eslam reda ragheb via GitGitGadget
2026-02-26 21:14 ` [PATCH v4 10/10] repo: reduce repetition in structure keyvalue output Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 00/11] repo info: add category/path keys and --path-format eslam reda via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 01/11] repo: teach info context and category keys Eslam reda ragheb via GitGitGadget
2026-02-27 21:42 ` Lucas Seiki Oshiro
2026-02-27 19:30 ` [PATCH v5 02/11] repo: add path keys to repo info Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 03/11] repo: add --path-format for info path output Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 04/11] repo: add structure max object size metrics Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 05/11] repo: add structure topology and path-depth metrics Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 06/11] repo: add aggregate structure totals to keyvalue output Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 07/11] t1900: cover repo info path keys and path-format Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 08/11] t1901: extend structure metric coverage and portability Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` [PATCH v5 09/11] docs: describe repo info path keys and structure metrics Eslam reda ragheb via GitGitGadget
2026-02-27 19:30 ` Eslam reda ragheb via GitGitGadget [this message]
2026-02-27 19:30 ` [PATCH v5 11/11] repo: refine path keys for repo info Eslam reda ragheb via GitGitGadget
2026-03-01 10:33 ` Phillip Wood
2026-02-27 21:52 ` [PATCH v5 00/11] repo info: add category/path keys and --path-format Lucas Seiki Oshiro
2026-03-02 5:15 ` [PATCH v6 0/6] " eslam reda via GitGitGadget
2026-03-02 5:15 ` [PATCH v6 1/6] repo: introduce repo_info context plumbing Eslam reda ragheb via GitGitGadget
2026-03-02 5:15 ` [PATCH v6 2/6] repo: support category requests in repo info Eslam reda ragheb via GitGitGadget
2026-03-02 5:15 ` [PATCH v6 3/6] repo: add path keys to " Eslam reda ragheb via GitGitGadget
2026-03-02 5:15 ` [PATCH v6 4/6] repo: add --path-format for info path output Eslam reda ragheb via GitGitGadget
2026-03-02 5:15 ` [PATCH v6 5/6] t1900: cover repo info path keys and path-format Eslam reda ragheb via GitGitGadget
2026-03-02 5:15 ` [PATCH v6 6/6] docs: describe repo info path keys Eslam reda ragheb via GitGitGadget
2026-03-18 20:44 ` [PATCH v6 0/6] repo info: add category/path keys and --path-format Jialong Wang
2026-03-19 3:36 ` K Jayatheerth
2026-03-19 20:32 ` Jerry Wang
2026-03-20 1:49 ` K Jayatheerth
2026-03-19 20:58 ` [PATCH v6 5/6] t1900: cover repo info path keys and path-format Jialong Wang
2026-03-19 20:59 ` [PATCH] t1900: cover repo info path keys in non-default layouts Jialong Wang
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=1bc100d6cab3b77badb5d79fb8133e22a35bd96e.1772220640.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=eslam.reda.div@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood123@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