]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-diff.c
filters/syntax-highlighting.sh: work around highlight --force bug
[ps-cgit] / ui-diff.c
index a7bc667f799cfd0e167508e90d0f5273d3c90f42..f8782df260c03a5231ecb740658caff4e3f8a583 100644 (file)
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -97,10 +97,12 @@ static void print_fileinfo(struct fileinfo *info)
        htmlf("</td><td class='%s'>", class);
        cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
                       ctx.qry.sha2, info->new_path, 0);
-       if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED)
-               htmlf(" (%s from %s)",
-                     info->status == DIFF_STATUS_COPIED ? "copied" : "renamed",
-                     info->old_path);
+       if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) {
+               htmlf(" (%s from ",
+                     info->status == DIFF_STATUS_COPIED ? "copied" : "renamed");
+               html_txt(info->old_path);
+               html(")");
+       }
        html("</td><td class='right'>");
        if (info->binary) {
                htmlf("bin</td><td class='graph'>%ld -> %ld bytes",
@@ -345,8 +347,10 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
                return;
        }
        commit = lookup_commit_reference(new_rev_sha1);
-       if (!commit || parse_commit(commit))
+       if (!commit || parse_commit(commit)) {
                cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(new_rev_sha1)));
+               return;
+       }
 
        if (old_rev)
                get_sha1(old_rev, old_rev_sha1);
@@ -362,12 +366,13 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
                        return;
                }
                commit2 = lookup_commit_reference(old_rev_sha1);
-               if (!commit2 || parse_commit(commit2))
+               if (!commit2 || parse_commit(commit2)) {
                        cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(old_rev_sha1)));
+                       return;
+               }
        }
 
-       if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
-               use_ssdiff = 1;
+       use_ssdiff = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff;
 
        print_ssdiff_link();
        cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);