From 279cdbf94bd5d88e064709eaead69aaf4f1d5254 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:30:00 -0700 Subject: Emit both blame side columns with one loop --- source/ui-blame.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'source/ui-blame.c') diff --git a/source/ui-blame.c b/source/ui-blame.c index 2f79d68..5c8dbd6 100644 --- a/source/ui-blame.c +++ b/source/ui-blame.c @@ -151,19 +151,6 @@ static void emit_entry_hash(struct blame_entry *ent) emit_chars('\n', ent->num_lines); } -static void emit_hashes(struct blame_scoreboard *sb) -{ - struct blame_entry *ent; - - html(""); - for (ent = sb->ent; ent; ent = ent->next) { - html("
");
-		emit_entry_hash(ent);
-		html("
"); - } - html("\n"); -} - static void emit_entry_linenumbers(struct blame_entry *ent) { struct strbuf numbers = STRBUF_INIT; @@ -181,14 +168,15 @@ static void emit_entry_linenumbers(struct blame_entry *ent) strbuf_release(&numbers); } -static void emit_linenumbers(struct blame_scoreboard *sb) +static void emit_column(struct blame_scoreboard *sb, const char *class, + void (*emit_entry)(struct blame_entry *ent)) { struct blame_entry *ent; - html(""); + htmlf("", class); for (ent = sb->ent; ent; ent = ent->next) { html("
");
-		emit_entry_linenumbers(ent);
+		emit_entry(ent);
 		html("
"); } html("\n"); @@ -310,10 +298,10 @@ static void print_blame_page(const struct object_id *oid, const char *path, } html("\n\n"); - emit_hashes(&sb); + emit_column(&sb, "hashes", emit_entry_hash); if (ctx.cfg.enable_tree_linenumbers) - emit_linenumbers(&sb); + emit_column(&sb, "linenumbers", emit_entry_linenumbers); html("
"); emit_line_backgrounds(&sb); -- cgit