[PATCH 3/3] cgit: zero-pad the cached repolist filename
Konstantin Ryabitsev
konstantin at linuxfoundation.org
Tue Aug 25 18:05:16 UTC 2026
The name of the cached repolist is built with "%8lx", which pads to eight
characters with spaces rather than with zeroes, so a hash below 0x10000000
produces a filename like "rc- 1234". Use "%08lx", which is what the
fixed width was evidently meant to be.
This is cosmetic and optional. hash_str() returns an unsigned long, so on a
64-bit host the hash is essentially always wider than eight characters and
neither conversion pads at all; the two differ only for the rare small hash
that would otherwise get spaces in its filename. Nothing misbehaves either
way, and because the change is confined to those cases it does not rename
any cache file that a running instance is likely to have.
Assisted-by: LLM [analysis, codegen]
Signed-off-by: Konstantin Ryabitsev <konstantin at linuxfoundation.org>
---
cgit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cgit.c b/cgit.c
index 2dfba9e..ffd8896 100644
--- a/cgit.c
+++ b/cgit.c
@@ -953,7 +953,7 @@ static void process_cached_repolist(const char *path)
hash = hash_str(path);
if (ctx.cfg.project_list)
hash += hash_str(ctx.cfg.project_list);
- strbuf_addf(&cached_rc, "%s/rc-%8lx", ctx.cfg.cache_root, hash);
+ strbuf_addf(&cached_rc, "%s/rc-%08lx", ctx.cfg.cache_root, hash);
if (stat(cached_rc.buf, &st)) {
/* Nothing is cached, we need to scan without forking. And
--
2.55.0
More information about the CGit
mailing list