diff options
context:
space:
mode:
-rw-r--r--source/ui-diff.c18
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;