From 91ed33e876815b986d6678737f7e74d71f0da749 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 25 Oct 2026 12:41:40 -1000 Subject: Give every summary section the same columns The ref rows always spanned five columns and the log three to five, so with the default config the log and clone rows stopped 160px short of the table's edge, and with any config the log rows did on a phone, where they alone lost their counts. A column no cell began in also made the summary and refs pages invalid HTML. --- source/ui-log.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'source/ui-log.c') diff --git a/source/ui-log.c b/source/ui-log.c index 98efcf6..2812246 100644 --- a/source/ui-log.c +++ b/source/ui-log.c @@ -212,7 +212,15 @@ static void print_graph_padding(struct rev_info *revs, struct strbuf *graph, int html("\n"); } -static void print_commit(struct commit *commit, struct rev_info *revs) +// Ends a row in a table wider than the log with an empty cell for each column +// the log has no use for. +static void print_filler(int columns) +{ + while (columns-- > 0) + html(""); +} + +static void print_commit(struct commit *commit, struct rev_info *revs, int filler) { struct commitinfo *info; int columns = revs->graph ? 4 : 3; @@ -223,6 +231,8 @@ static void print_commit(struct commit *commit, struct rev_info *revs) columns++; if (ctx.repo->enable_log_linecount) columns++; + // The rows that span the table reach across the filler as well. + columns += filler; if (revs->graph) print_graph_above(revs, &graphbuf, columns); @@ -270,7 +280,9 @@ static void print_commit(struct commit *commit, struct rev_info *revs) htmlf("-%d/" "+%d", removed_lines, added_lines); - html("\n"); + html(""); + print_filler(filler); + html("\n"); if ((revs->graph && !graph_is_commit_finished(revs->graph)) || ctx.qry.showmsg) { html(""); @@ -449,12 +461,12 @@ void cgit_print_commit_decorations(struct commit *commit) } void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, - const char *path, int pager, int commit_graph, int commit_sort) + const char *path, int pager, int commit_graph, int commit_sort, int table_columns) { struct rev_info rev; struct commit *commit; struct strvec rev_argv = STRVEC_INIT; - int i, columns = commit_graph ? 4 : 3; + int i, columns = commit_graph ? 4 : 3, filler = 0; int must_free_tip = 0; // setup_revisions skips the first entry the way a command skips its @@ -591,6 +603,9 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern html("Lines"); columns++; } + if (table_columns > columns) + filler = table_columns - columns; + print_filler(filler); html("\n"); if (ofs < 0) @@ -609,7 +624,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern counts_ready = 0; if (should_show(commit, &rev)) { i++; - print_commit(commit, &rev); + print_commit(commit, &rev, filler); } release_commit_memory(the_repository->parsed_objects, commit); commit->parents = NULL; @@ -619,7 +634,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern cgit_print_layout_end(); } else { if (get_revision(&rev)) { - htmlf("", columns); + htmlf("", columns + filler); cgit_log_link( "[...]", NULL, NULL, ctx.qry.head, NULL, ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, ctx.qry.follow -- cgit 2.9.2