diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Fix diffstat and submodule diff output
The diffstat divided by zero when a commit changed no lines, and a
submodule change was printed with a hardcoded length that dropped a
digit of a sha-1 and most of a sha-256.
| -rw-r--r-- | source/ui-diff.c | 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 11 insertions, 7 deletions
diff --git a/source/ui-diff.c b/source/ui-diff.c index 6cfa697..04bbecc 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -117,11 +117,11 @@ static void print_fileinfo(struct fileinfo *info) html("</td><td class='graph'>"); htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes)); htmlf("<td class='add' style='width: %.1f%%;'/>", - info->added * 100.0 / max_changes); + info->added * 100.0 / (max_changes ? max_changes : 1)); htmlf("<td class='rem' style='width: %.1f%%;'/>", - info->removed * 100.0 / max_changes); + info->removed * 100.0 / (max_changes ? max_changes : 1)); htmlf("<td class='none' style='width: %.1f%%;'/>", - (max_changes - info->removed - info->added) * 100.0 / max_changes); + (max_changes - info->removed - info->added) * 100.0 / (max_changes ? max_changes : 1)); html("</tr></table></td></tr>\n"); } @@ -314,10 +314,14 @@ static void filepair_cb(struct diff_filepair *pair) if (use_ssdiff) cgit_ssdiff_header_end(); if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { - if (S_ISGITLINK(pair->one->mode)) - print_line_fn(fmt("-Subproject %s", oid_to_hex(&pair->one->oid)), 52); - if (S_ISGITLINK(pair->two->mode)) - print_line_fn(fmt("+Subproject %s", oid_to_hex(&pair->two->oid)), 52); + if (S_ISGITLINK(pair->one->mode)) { + char *l = fmt("-Subproject %s", oid_to_hex(&pair->one->oid)); + print_line_fn(l, strlen(l) + 1); + } + if (S_ISGITLINK(pair->two->mode)) { + char *l = fmt("+Subproject %s", oid_to_hex(&pair->two->oid)); + print_line_fn(l, strlen(l) + 1); + } if (use_ssdiff) cgit_ssdiff_footer(); return; |
