Website Summary Files Commits Branches @commit @diff @stats
path: root / ui-tree.c
diff options
context:
space:
mode:
Commit47f1595e49218f016179aab2e39207fe203da54a (patch)
Author
 Syndamia <kamen@syndamia.com>
2026-09-27 22:04:57 +0300
Committer
 Syndamia <kamen@syndamia.com>
2026-09-27 22:14:30 +0300
Files402fc2e3e97b6545c2a53502c9e1c47199dfdb89 /ui-tree.c
cgit-47f1595e49218f016179aab2e39207fe203da54a.tar
cgit-47f1595e49218f016179aab2e39207fe203da54a.tar.gz
cgit-47f1595e49218f016179aab2e39207fe203da54a.zip
Parent81a502f3f6579c6d69dab2485bdbc4fc35d9748c (diff)
ui-tree: Human-readable file sizes
1 files changed, 9 insertions, 1 deletions
-rw-r--r--ui-tree.c10
diff --git a/ui-tree.c b/ui-tree.c
index 5ac8c9a..6a16c21 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -257,7 +257,15 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,
free(buf);
strbuf_release(&linkpath);
}
- htmlf("</td><td class='ls-size'>%li</td>", size);
+
+ if (size < 1024)
+ htmlf("</td><td class='ls-size'>%li&nbsp;B</td>", size);
+ else if (size < 1048576)
+ htmlf("</td><td class='ls-size'>%.1f&nbsp;KiB</td>", (double)size / 1024);
+ else if (size < 1073741824)
+ htmlf("</td><td class='ls-size'>%.1f&nbsp;MiB</td>", (double)size / 1048576);
+ else
+ htmlf("</td><td class='ls-size'>%.1f&nbsp;GiB</td>", (double)size / 1073741824);
html("<td>");
cgit_log_link("log", NULL, "button", ctx.qry.head,