diff options
Diffstat (limited to 'ui-commit.c')
-rw-r--r-- | ui-commit.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/ui-commit.c b/ui-commit.c index b5e3c01..a11bc5f 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -12,13 +12,13 @@ | |||
12 | #include "ui-diff.h" | 12 | #include "ui-diff.h" |
13 | #include "ui-log.h" | 13 | #include "ui-log.h" |
14 | 14 | ||
15 | void cgit_print_commit(char *hex) | 15 | void cgit_print_commit(char *hex, const char *prefix) |
16 | { | 16 | { |
17 | struct commit *commit, *parent; | 17 | struct commit *commit, *parent; |
18 | struct commitinfo *info; | 18 | struct commitinfo *info, *parent_info; |
19 | struct commit_list *p; | 19 | struct commit_list *p; |
20 | unsigned char sha1[20]; | 20 | unsigned char sha1[20]; |
21 | char *tmp; | 21 | char *tmp, *tmp2; |
22 | int parents = 0; | 22 | int parents = 0; |
23 | 23 | ||
24 | if (!hex) | 24 | if (!hex) |
@@ -58,19 +58,23 @@ void cgit_print_commit(char *hex) | |||
58 | html("</td></tr>\n"); | 58 | html("</td></tr>\n"); |
59 | html("<tr><th>commit</th><td colspan='2' class='sha1'>"); | 59 | html("<tr><th>commit</th><td colspan='2' class='sha1'>"); |
60 | tmp = sha1_to_hex(commit->object.sha1); | 60 | tmp = sha1_to_hex(commit->object.sha1); |
61 | cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, 0); | 61 | cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0); |
62 | html(" ("); | 62 | html(" ("); |
63 | cgit_patch_link("patch", NULL, NULL, NULL, tmp); | 63 | cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix); |
64 | html(") ("); | 64 | html(") ("); |
65 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) | 65 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) |
66 | cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, 1); | 66 | cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1); |
67 | else | 67 | else |
68 | cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, 1); | 68 | cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1); |
69 | html(")</td></tr>\n"); | 69 | html(")</td></tr>\n"); |
70 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); | 70 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); |
71 | tmp = xstrdup(hex); | 71 | tmp = xstrdup(hex); |
72 | cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, | 72 | cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, |
73 | ctx.qry.head, tmp, NULL); | 73 | ctx.qry.head, tmp, NULL); |
74 | if (prefix) { | ||
75 | html(" /"); | ||
76 | cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix); | ||
77 | } | ||
74 | html("</td></tr>\n"); | 78 | html("</td></tr>\n"); |
75 | for (p = commit->parents; p ; p = p->next) { | 79 | for (p = commit->parents; p ; p = p->next) { |
76 | parent = lookup_commit_reference(p->item->object.sha1); | 80 | parent = lookup_commit_reference(p->item->object.sha1); |
@@ -82,11 +86,15 @@ void cgit_print_commit(char *hex) | |||
82 | } | 86 | } |
83 | html("<tr><th>parent</th>" | 87 | html("<tr><th>parent</th>" |
84 | "<td colspan='2' class='sha1'>"); | 88 | "<td colspan='2' class='sha1'>"); |
85 | cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, | 89 | tmp = tmp2 = sha1_to_hex(p->item->object.sha1); |
86 | ctx.qry.head, sha1_to_hex(p->item->object.sha1), 0); | 90 | if (ctx.repo->enable_subject_links) { |
91 | parent_info = cgit_parse_commit(parent); | ||
92 | tmp2 = parent_info->subject; | ||
93 | } | ||
94 | cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0); | ||
87 | html(" ("); | 95 | html(" ("); |
88 | cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, | 96 | cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, |
89 | sha1_to_hex(p->item->object.sha1), NULL, 0); | 97 | sha1_to_hex(p->item->object.sha1), prefix, 0); |
90 | html(")</td></tr>"); | 98 | html(")</td></tr>"); |
91 | parents++; | 99 | parents++; |
92 | } | 100 | } |
@@ -117,7 +125,7 @@ void cgit_print_commit(char *hex) | |||
117 | tmp = sha1_to_hex(commit->parents->item->object.sha1); | 125 | tmp = sha1_to_hex(commit->parents->item->object.sha1); |
118 | else | 126 | else |
119 | tmp = NULL; | 127 | tmp = NULL; |
120 | cgit_print_diff(ctx.qry.sha1, tmp, NULL); | 128 | cgit_print_diff(ctx.qry.sha1, tmp, prefix); |
121 | } | 129 | } |
122 | cgit_free_commitinfo(info); | 130 | cgit_free_commitinfo(info); |
123 | } | 131 | } |