X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/9fb53af215639fcd3bfb876fa9c8bac221244bdf..dc3ac3f76077c5d612d42e8beb4878e43acfc58a:/ui-commit.c diff --git a/ui-commit.c b/ui-commit.c index 20a7cb2..ff1fad3 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -8,11 +8,11 @@ #include "cgit.h" -int files = 0, slots = 0; -int total_adds = 0, total_rems = 0, max_changes = 0; -int lines_added, lines_removed; +static int files, slots; +static int total_adds, total_rems, max_changes; +static int lines_added, lines_removed; -struct fileinfo { +static struct fileinfo { char status; unsigned char old_sha1[20]; unsigned char new_sha1[20]; @@ -29,7 +29,6 @@ void print_fileinfo(struct fileinfo *info) { char *query, *query2; char *class; - double width; switch (info->status) { case DIFF_STATUS_ADDED: @@ -96,18 +95,15 @@ void print_fileinfo(struct fileinfo *info) } html(""); htmlf("%d", info->added + info->removed); - html(""); - width = (info->added + info->removed) * 100.0 / max_changes; - if (width < 0.1) - width = 0.1; - html_link_open(cgit_pageurl(cgit_query_repo, "diff", query), - NULL, NULL); - htmlf("", - info->added * width / (info->added + info->removed)); - htmlf("", - info->removed * width / (info->added + info->removed)); - html("\n"); + htmlf("", (max_changes > 100 ? 100 : max_changes)); + htmlf("
", + info->added * 100.0 / max_changes); + htmlf("", + info->removed * 100.0 / max_changes); + htmlf("", + (max_changes - info->removed - info->added) * 100.0 / max_changes); + html("
\n"); } void cgit_count_diff_lines(char *line, int len) @@ -201,7 +197,7 @@ void cgit_print_commit(const char *hex) html("parent" "" "%s (Diffstat"); html(""); max_changes = 0; cgit_diff_commit(commit, inspect_filepair); @@ -232,8 +229,11 @@ void cgit_print_commit(const char *hex) print_fileinfo(&items[i]); html("
"); html("
"); - htmlf("%d files changed, %d insertions, %d deletions\n", + htmlf("%d files changed, %d insertions, %d deletions (", files, total_adds, total_rems); + query = fmt("h=%s", hex); + html_link_open(cgit_pageurl(cgit_query_repo, "diff", query), NULL, NULL); + html("show diff)"); html("
"); } cgit_free_commitinfo(info);