author | Lars Hjemli <hjemli@gmail.com> | 2007-05-15 22:58:35 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-15 22:58:35 (UTC) |
commit | f9ff7df613b4ee86fe5914c4ae3400650882c03d (patch) (unidiff) | |
tree | c26fde3a4d3485943c275232f18359bebd133f1a | |
parent | a2ddc10479ec463708e422ca5ce7ec02c22a7d02 (diff) | |
download | cgit-f9ff7df613b4ee86fe5914c4ae3400650882c03d.zip cgit-f9ff7df613b4ee86fe5914c4ae3400650882c03d.tar.gz cgit-f9ff7df613b4ee86fe5914c4ae3400650882c03d.tar.bz2 |
Add support for commitdiff via h parameter
The commitdiff will be generated against the first parent, and the
diff page also gets the benefit of repo.defbranch.
Cleaned up some bad whitespace in cgit.h while at it.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 11 | ||||
-rw-r--r-- | ui-diff.c | 14 |
3 files changed, 21 insertions, 7 deletions
@@ -121,5 +121,6 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
121 | cgit_print_view(cgit_query_sha1, cgit_query_path); | 121 | cgit_print_view(cgit_query_sha1, cgit_query_path); |
122 | } else if (!strcmp(cgit_query_page, "diff")) { | 122 | } else if (!strcmp(cgit_query_page, "diff")) { |
123 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); | 123 | cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2, |
124 | cgit_query_path); | ||
124 | } else { | 125 | } else { |
125 | cgit_print_error("Invalid request"); | 126 | cgit_print_error("Invalid request"); |
@@ -158,5 +158,5 @@ extern int cache_expired(struct cacheitem *item); | |||
158 | 158 | ||
159 | extern char *cgit_repourl(const char *reponame); | 159 | extern char *cgit_repourl(const char *reponame); |
160 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 160 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
161 | const char *query); | 161 | const char *query); |
162 | 162 | ||
@@ -166,6 +166,6 @@ extern void cgit_print_docstart(char *title, struct cacheitem *item); | |||
166 | extern void cgit_print_docend(); | 166 | extern void cgit_print_docend(); |
167 | extern void cgit_print_pageheader(char *title, int show_search); | 167 | extern void cgit_print_pageheader(char *title, int show_search); |
168 | extern void cgit_print_snapshot_start(const char *mimetype, | 168 | extern void cgit_print_snapshot_start(const char *mimetype, |
169 | const char *filename, | 169 | const char *filename, |
170 | struct cacheitem *item); | 170 | struct cacheitem *item); |
171 | 171 | ||
@@ -177,6 +177,7 @@ extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path) | |||
177 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); | 177 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); |
178 | extern void cgit_print_commit(const char *hex); | 178 | extern void cgit_print_commit(const char *hex); |
179 | extern void cgit_print_diff(const char *old_hex, const char *new_hex, char *path); | 179 | extern void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, |
180 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, | 180 | char *path); |
181 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, | ||
181 | const char *format, const char *prefix, | 182 | const char *format, const char *prefix, |
182 | const char *filename); | 183 | const char *filename); |
@@ -67,9 +67,21 @@ static void filepair_cb(struct diff_filepair *pair) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | void cgit_print_diff(const char *old_hex, const char *new_hex, char *path) | 69 | void cgit_print_diff(const char *head, const char *old_hex, const char *new_hex, char *path) |
70 | { | 70 | { |
71 | unsigned char sha1[20], sha2[20]; | 71 | unsigned char sha1[20], sha2[20]; |
72 | enum object_type type; | 72 | enum object_type type; |
73 | unsigned long size; | 73 | unsigned long size; |
74 | struct commit *commit; | ||
75 | |||
76 | if (head && !old_hex && !new_hex) { | ||
77 | get_sha1(head, sha1); | ||
78 | commit = lookup_commit_reference(sha1); | ||
79 | if (commit && !parse_commit(commit)) { | ||
80 | html("<table class='diff'>"); | ||
81 | cgit_diff_commit(commit, filepair_cb); | ||
82 | html("</td></tr></table>"); | ||
83 | } | ||
84 | return; | ||
85 | } | ||
74 | 86 | ||
75 | get_sha1(old_hex, sha1); | 87 | get_sha1(old_hex, sha1); |