mirror of
https://git.zx2c4.com/cgit
synced 2024-11-23 00:48:42 +00:00
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>
This commit is contained in:
parent
a2ddc10479
commit
f9ff7df613
3
cgit.c
3
cgit.c
@ -120,7 +120,8 @@ static void cgit_print_repo_page(struct cacheitem *item)
|
|||||||
} else if (!strcmp(cgit_query_page, "view")) {
|
} else if (!strcmp(cgit_query_page, "view")) {
|
||||||
cgit_print_view(cgit_query_sha1, cgit_query_path);
|
cgit_print_view(cgit_query_sha1, cgit_query_path);
|
||||||
} else if (!strcmp(cgit_query_page, "diff")) {
|
} 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 {
|
} else {
|
||||||
cgit_print_error("Invalid request");
|
cgit_print_error("Invalid request");
|
||||||
}
|
}
|
||||||
|
3
cgit.h
3
cgit.h
@ -176,7 +176,8 @@ extern void cgit_print_view(const char *hex, char *path);
|
|||||||
extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
|
extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
|
||||||
extern void cgit_print_tree(const char *rev, const char *hex, char *path);
|
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_commit(const char *hex);
|
||||||
extern void cgit_print_diff(const char *old_hex, const char *new_hex, char *path);
|
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,
|
extern void cgit_print_snapshot(struct cacheitem *item, const char *hex,
|
||||||
const char *format, const char *prefix,
|
const char *format, const char *prefix,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
|
14
ui-diff.c
14
ui-diff.c
@ -66,11 +66,23 @@ static void filepair_cb(struct diff_filepair *pair)
|
|||||||
html("</tr></td>");
|
html("</tr></td>");
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
unsigned char sha1[20], sha2[20];
|
unsigned char sha1[20], sha2[20];
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
get_sha1(old_hex, sha1);
|
get_sha1(old_hex, sha1);
|
||||||
get_sha1(new_hex, sha2);
|
get_sha1(new_hex, sha2);
|
||||||
|
Loading…
Reference in New Issue
Block a user