summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c3
-rw-r--r--cgit.h11
-rw-r--r--ui-diff.c14
3 files changed, 21 insertions, 7 deletions
diff --git a/cgit.c b/cgit.c
index 9b4815d..3e7e595 100644
--- a/cgit.c
+++ b/cgit.c
@@ -122,3 +122,4 @@ static void cgit_print_repo_page(struct cacheitem *item)
} else if (!strcmp(cgit_query_page, "diff")) {
- cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path);
+ cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2,
+ cgit_query_path);
} else {
diff --git a/cgit.h b/cgit.h
index ac710a6..764225d 100644
--- a/cgit.h
+++ b/cgit.h
@@ -159,3 +159,3 @@ extern int cache_expired(struct cacheitem *item);
extern char *cgit_repourl(const char *reponame);
-extern char *cgit_pageurl(const char *reponame, const char *pagename,
+extern char *cgit_pageurl(const char *reponame, const char *pagename,
const char *query);
@@ -167,4 +167,4 @@ extern void cgit_print_docend();
extern void cgit_print_pageheader(char *title, int show_search);
-extern void cgit_print_snapshot_start(const char *mimetype,
- const char *filename,
+extern void cgit_print_snapshot_start(const char *mimetype,
+ const char *filename,
struct cacheitem *item);
@@ -178,4 +178,5 @@ extern void cgit_print_tree(const char *rev, const char *hex, char *path);
extern void cgit_print_commit(const char *hex);
-extern void cgit_print_diff(const char *old_hex, const char *new_hex, char *path);
-extern void cgit_print_snapshot(struct cacheitem *item, const char *hex,
+extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex,
+ char *path);
+extern void cgit_print_snapshot(struct cacheitem *item, const char *hex,
const char *format, const char *prefix,
diff --git a/ui-diff.c b/ui-diff.c
index 999b6f3..afe1c90 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -68,3 +68,3 @@ static void filepair_cb(struct diff_filepair *pair)
-void cgit_print_diff(const char *old_hex, const char *new_hex, char *path)
+void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, char *path)
{
@@ -73,2 +73,14 @@ void cgit_print_diff(const char *old_hex, const char *new_hex, char *path)
unsigned long size;
+ struct commit *commit;
+
+ if (head && !old_hex && !new_hex) {
+ get_sha1(head, sha1);
+ commit = lookup_commit_reference(sha1);
+ if (commit && !parse_commit(commit)) {
+ html("<table class='diff'>");
+ cgit_diff_commit(commit, filepair_cb);
+ html("</td></tr></table>");
+ }
+ return;
+ }