From d8a045c91469b1d121b8fd14dffaa367b194831d Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 6 Sep 2026 21:46:52 -1000 Subject: Clean up the whole tree --- source/ui-log.c | 125 ++++++++++++++++++++++---------------------------------- 1 file changed, 49 insertions(+), 76 deletions(-) (limited to 'source/ui-log.c') diff --git a/source/ui-log.c b/source/ui-log.c index 5b5dd32..8fe58f9 100644 --- a/source/ui-log.c +++ b/source/ui-log.c @@ -64,9 +64,8 @@ static void count_file(struct diff_filepair *pair) file_count++; if (ctx.repo->enable_log_linecount) - cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size, - &new_size, &binary, 0, ctx.qry.ignorews, - count_line); + cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size, &new_size, + &binary, 0, ctx.qry.ignorews, count_line); } /* @@ -122,9 +121,7 @@ static int should_show(struct commit *commit, struct rev_info *revs) removed_lines = 0; revs->diffopt.flags.recursive = 1; - diff_tree_oid(get_commit_tree_oid(parent), - get_commit_tree_oid(commit), - "", &revs->diffopt); + diff_tree_oid(get_commit_tree_oid(parent), get_commit_tree_oid(commit), "", &revs->diffopt); diffcore_std(&revs->diffopt); found = !diff_queue_is_empty(&revs->diffopt); @@ -146,8 +143,7 @@ static int should_show(struct commit *commit, struct rev_info *revs) * commit itself stays in graph for the caller to place in the commit's own * row. */ -static void print_graph_above(struct rev_info *revs, struct strbuf *graph, - int columns) +static void print_graph_above(struct rev_info *revs, struct strbuf *graph, int columns) { while (!graph_next_line(revs->graph, graph)) { html(""); @@ -171,8 +167,7 @@ static void wrap_subject(struct commitinfo *info, struct strbuf *msg) size_t subject_len = strlen(info->subject); int cut; - if (ctx.cfg.max_msg_len < MIN_WRAP_LEN || - subject_len <= (size_t)ctx.cfg.max_msg_len) + if (ctx.cfg.max_msg_len < MIN_WRAP_LEN || subject_len <= (size_t)ctx.cfg.max_msg_len) return; cut = ctx.cfg.max_msg_len - strlen(wrap_symbol); @@ -199,8 +194,7 @@ static int line_count(const char *text) return lines; } -static void print_graph_padding(struct rev_info *revs, struct strbuf *graph, - int lines) +static void print_graph_padding(struct rev_info *revs, struct strbuf *graph, int lines) { html(""); while (lines > 0 || !graph_is_commit_finished(revs->graph)) { @@ -237,11 +231,9 @@ static void print_commit(struct commit *commit, struct rev_info *revs) html(graphbuf.buf); html(""); strbuf_setlen(&graphbuf, 0); - } - else { + } else { html(""); - cgit_print_age(info->committer_date, info->committer_tz, - MAX_RELATIVE_AGE); + cgit_print_age(info->committer_date, info->committer_tz, MAX_RELATIVE_AGE); html(""); } @@ -249,7 +241,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs) if (ctx.qry.showmsg) wrap_subject(info, &msgbuf); cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, - oid_to_hex(&commit->object.oid), ctx.qry.vpath); + oid_to_hex(&commit->object.oid), ctx.qry.vpath); cgit_print_commit_decorations(commit); html(""); cgit_open_filter(ctx.repo->email_filter, info->author_email, "log"); @@ -258,12 +250,10 @@ static void print_commit(struct commit *commit, struct rev_info *revs) if (revs->graph) { html(""); - cgit_print_age(info->committer_date, info->committer_tz, - MAX_RELATIVE_AGE); + cgit_print_age(info->committer_date, info->committer_tz, MAX_RELATIVE_AGE); } - if (!counts_ready && (ctx.repo->enable_log_filecount || - ctx.repo->enable_log_linecount)) { + if (!counts_ready && (ctx.repo->enable_log_filecount || ctx.repo->enable_log_linecount)) { file_count = 0; added_lines = 0; removed_lines = 0; @@ -274,13 +264,11 @@ static void print_commit(struct commit *commit, struct rev_info *revs) htmlf("%d", file_count); if (ctx.repo->enable_log_linecount) htmlf("-%d/" - "+%d", - removed_lines, added_lines); + "+%d", removed_lines, added_lines); html("\n"); - if ((revs->graph && !graph_is_commit_finished(revs->graph)) - || ctx.qry.showmsg) { + if ((revs->graph && !graph_is_commit_finished(revs->graph)) || ctx.qry.showmsg) { html(""); if (ctx.qry.showmsg) { @@ -288,26 +276,22 @@ static void print_commit(struct commit *commit, struct rev_info *revs) strbuf_addstr(&msgbuf, info->msg); strbuf_addch(&msgbuf, '\n'); } - format_display_notes(&commit->object.oid, - &msgbuf, PAGE_ENCODING, 0); + format_display_notes(&commit->object.oid, &msgbuf, PAGE_ENCODING, 0); strbuf_addch(&msgbuf, '\n'); strbuf_ltrim(&msgbuf); } // With no graph the empty cell stands in for the age column. if (revs->graph) { - int msg_lines = ctx.qry.showmsg ? - line_count(msgbuf.buf) : 0; + int msg_lines = ctx.qry.showmsg ? line_count(msgbuf.buf) : 0; print_graph_padding(revs, &graphbuf, msg_lines); - } - else + } else html(""); // Either way one cell is already on the row, so the message // spans the remaining columns. - htmlf("\n", columns - 1, - ctx.qry.showmsg ? " class='logmsg'" : ""); + htmlf("\n", columns - 1, ctx.qry.showmsg ? " class='logmsg'" : ""); html_txt(msgbuf.buf); html("\n"); } @@ -370,20 +354,18 @@ static void print_pager(struct rev_info *revs, int ofs, int cnt) html(""); @@ -411,31 +393,25 @@ void cgit_print_commit_decorations(struct commit *commit) case DECORATION_NONE: break; case DECORATION_REF_LOCAL: - cgit_log_link(buf, NULL, "branch-deco", buf, NULL, - ctx.qry.vpath, 0, NULL, NULL, - ctx.qry.showmsg, 0); + cgit_log_link(buf, NULL, "branch-deco", buf, NULL, ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, 0); break; case DECORATION_REF_TAG: - if (!refs_read_ref(get_main_ref_store(the_repository), - deco->name, &oid_tag) && - !peel_object(the_repository, &oid_tag, &peeled, - PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE)) + if (!refs_read_ref(get_main_ref_store(the_repository), deco->name, &oid_tag) && + !peel_object(the_repository, &oid_tag, &peeled, + PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE)) is_annotated = !oideq(&oid_tag, &peeled); - cgit_tag_link(buf, NULL, is_annotated ? - "tag-annotated-deco" : "tag-deco", buf); + cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf); break; case DECORATION_REF_REMOTE: if (!ctx.repo->enable_remote_branches) break; - cgit_log_link(buf, NULL, "remote-deco", NULL, - oid_to_hex(&commit->object.oid), - ctx.qry.vpath, 0, NULL, NULL, - ctx.qry.showmsg, 0); + cgit_log_link( + buf, NULL, "remote-deco", NULL, oid_to_hex(&commit->object.oid), + ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, 0 + ); break; default: - cgit_commit_link(buf, NULL, "deco", ctx.qry.head, - oid_to_hex(&commit->object.oid), - ctx.qry.vpath); + cgit_commit_link(buf, NULL, "deco", ctx.qry.head, oid_to_hex(&commit->object.oid), ctx.qry.vpath); break; } deco = deco->next; @@ -443,9 +419,8 @@ void cgit_print_commit_decorations(struct commit *commit) html(""); } -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) +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) { struct rev_info rev; struct commit *commit; @@ -475,8 +450,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, if (grep && pattern && *pattern) { pattern = xstrdup(pattern); - if (!strcmp(grep, "grep") || !strcmp(grep, "author") || - !strcmp(grep, "committer")) { + if (!strcmp(grep, "grep") || !strcmp(grep, "author") || !strcmp(grep, "committer")) { strvec_pushf(&rev_argv, "--%s=%s", grep, pattern); } else if (!strcmp(grep, "range")) { char *arg; @@ -489,8 +463,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, strvec_pop(&rev_argv); while ((arg = next_token(&pattern))) { if (*arg == '-') { - fprintf(stderr, "[cgit] Bad range expression: %s\n", - arg); + fprintf(stderr, "[cgit] Bad range expression: %s\n", arg); break; } strvec_push(&rev_argv, arg); @@ -504,8 +477,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, if (commit_graph && !ctx.qry.follow) { strvec_push(&rev_argv, "--graph"); strvec_push(&rev_argv, "--color"); - graph_set_column_colors(column_colors_html, - COLUMN_COLORS_HTML_MAX); + graph_set_column_colors(column_colors_html, COLUMN_COLORS_HTML_MAX); } if (commit_sort == 1) @@ -552,11 +524,11 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, html("Commit message"); if (pager) { html(" ("); - cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, - NULL, ctx.qry.head, ctx.qry.oid, - ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep, - ctx.qry.search, ctx.qry.showmsg ? 0 : 1, - ctx.qry.follow); + cgit_log_link( + ctx.qry.showmsg ? "Collapse" : "Expand", NULL, NULL, ctx.qry.head, + ctx.qry.oid, ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep, ctx.qry.search, + ctx.qry.showmsg ? 0 : 1, ctx.qry.follow + ); html(")"); } html("Author"); @@ -598,9 +570,10 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, cgit_print_layout_end(); } else if ((commit = get_revision(&rev)) != NULL) { htmlf("", columns); - cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, - ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, - ctx.qry.follow); + cgit_log_link( + "[...]", NULL, NULL, ctx.qry.head, NULL, ctx.qry.vpath, 0, + NULL, NULL, ctx.qry.showmsg, ctx.qry.follow + ); html("\n"); } -- cgit v2.8.0