]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-patch.c
Use GIT-1.6.0-rc0
[ps-cgit] / ui-patch.c
index a77f3f6cccc67ea85029eba247c61f8470303fa5..c1c4ce30368d668b954d460a4df3b836da58db4f 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "cgit.h"
 #include "html.h"
+#include "ui-shared.h"
 
 static void print_line(char *line, int len)
 {
@@ -69,7 +70,7 @@ static void filepair_cb(struct diff_filepair *pair)
                html("Error running diff");
 }
 
-void cgit_print_patch(char *hex, struct cacheitem *item)
+void cgit_print_patch(char *hex)
 {
        struct commit *commit;
        struct commitinfo *info;
@@ -89,7 +90,11 @@ void cgit_print_patch(char *hex, struct cacheitem *item)
                return;
        }
        info = cgit_parse_commit(commit);
-       hashcpy(old_sha1, commit->parents->item->object.sha1);
+
+       if (commit->parents && commit->parents->item)
+               hashcpy(old_sha1, commit->parents->item->object.sha1);
+       else
+               hashclr(old_sha1);
 
        patchname = fmt("%s.patch", sha1_to_hex(sha1));
        ctx.page.mimetype = "text/plain";