]> Kevux Git Server - rit/commit
strbuf: split out logic to humanise byte values
authorJustin Tobler <jltobler@gmail.com>
Wed, 17 Dec 2025 17:53:59 +0000 (11:53 -0600)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Dec 2025 00:02:31 +0000 (09:02 +0900)
commitce849b1851102d974653701564573798034492d5
treed05b75c1178c6e2e6420daca5dc81be139583841
parent9faaf254ba061e9fc7065f4c940c9dfcc51e6bbe
strbuf: split out logic to humanise byte values

In a subsequent commit, byte size values displayed in table output for
the git-repo(1) "structure" subcommand will be shown in a more
human-readable format with the appropriate unit prefixes. For this
usecase, the downscaled values and unit strings must be handled
separately to ensure proper column alignment.

Split out logic from strbuf_humanise() to downscale byte values and
determine the corresponding unit prefix into a separate humanise_bytes()
function that provides seperate value and unit strings.

Note that the "byte" string in "t/helper/test-simple-ipc.c" is unmarked
for translation here so that it doesn't conflict with the newly defined
plural "byte/bytes" translation and instead uses it.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strbuf.c
strbuf.h
t/helper/test-simple-ipc.c