From: Justin Tobler Date: Fri, 12 Dec 2025 16:46:28 GMT Subject: Re: [PATCH 2/6] builtin/repo: humanise count values in structure output Message-ID: In-Reply-To: On 25/12/11 11:57AM, Junio C Hamano wrote: > Justin Tobler writes: > > > On 25/12/10 07:28AM, Patrick Steinhardt wrote: > >> On Tue, Dec 09, 2025 at 04:58:16PM -0600, Justin Tobler wrote: > >> > diff --git a/builtin/repo.c b/builtin/repo.c > >> > index a69699857a..8fb728b3a5 100644 > >> > --- a/builtin/repo.c > >> > +++ b/builtin/repo.c > >> > @@ -266,6 +275,10 @@ static void stats_table_addf(struct stats_table *table, const char *format, ...) > >> > va_end(ap); > >> > } > >> > > >> > +static const char *unit_k = "k"; > >> > +static const char *unit_M = "M"; > >> > +static const char *unit_G = "G"; > >> > + > >> > static void stats_table_count_addf(struct stats_table *table, size_t value, > >> > const char *format, ...) > >> > { > >> > >> I would assume that these units should be translatable. > > > > Ya, you are right. I'll make units translatable in the next version. > > Whatever you do, please first consider reusing existing > "human-readable numbers" helpers, like strbuf_humanise_bytes() used > by the progress.c for showing throughput, before rolling your own > variant like the above. Ya, I originally looked into using strbuf_humanise_bytes(), but went a different direction due do how I wanted to align the values and unit prefixes in the table output. In the next version though, I'm trying to split out and reuse some of the same logic to avoid the duplication. -Justin