X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/bf8293d3196d49d6c4a48b254a04415183ca2762..6d6f8bdeed0b47422337c430fdaf236b978f6c44:/ui-patch.c diff --git a/ui-patch.c b/ui-patch.c index ca008f3..fbb92cc 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -7,6 +7,7 @@ */ #include "cgit.h" +#include "ui-patch.h" #include "html.h" #include "ui-shared.h" @@ -28,11 +29,6 @@ static void header(unsigned char *sha1, char *path1, int mode1, subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2)); htmlf("diff --git a/%s b/%s\n", path1, path2); - if (is_null_sha1(sha1)) - path1 = "dev/null"; - if (is_null_sha1(sha2)) - path2 = "dev/null"; - if (mode1 == 0) htmlf("new file mode %.6o\n", mode2); @@ -50,8 +46,18 @@ static void header(unsigned char *sha1, char *path1, int mode1, if (mode2 != mode1) htmlf("..%.6o", mode2); } - htmlf("\n--- a/%s\n", path1); - htmlf("+++ b/%s\n", path2); + + if (is_null_sha1(sha1)) { + path1 = "dev/null"; + htmlf("\n--- /%s\n", path1); + } else + htmlf("\n--- a/%s\n", path1); + + if (is_null_sha1(sha2)) { + path2 = "dev/null"; + htmlf("+++ /%s\n", path2); + } else + htmlf("+++ b/%s\n", path2); } } @@ -88,12 +94,12 @@ void cgit_print_patch(char *hex, const char *prefix) hex = ctx.qry.head; if (get_sha1(hex, sha1)) { - cgit_print_error(fmt("Bad object id: %s", hex)); + cgit_print_error("Bad object id: %s", hex); return; } commit = lookup_commit_reference(sha1); if (!commit) { - cgit_print_error(fmt("Bad commit reference: %s", hex)); + cgit_print_error("Bad commit reference: %s", hex); return; } info = cgit_parse_commit(commit); @@ -126,6 +132,6 @@ void cgit_print_patch(char *hex, const char *prefix) htmlf("(limited to '%s')\n\n", prefix); cgit_diff_tree(old_sha1, sha1, filepair_cb, prefix, 0); html("--\n"); - htmlf("cgit %s\n", CGIT_VERSION); + htmlf("cgit %s\n", cgit_version); cgit_free_commitinfo(info); }