summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.css18
-rw-r--r--cgit.h1
-rw-r--r--ui-commit.c15
3 files changed, 34 insertions, 0 deletions
diff --git a/cgit.css b/cgit.css
index 6e47eb3..3675697 100644
--- a/cgit.css
+++ b/cgit.css
@@ -281,96 +281,114 @@ table.bin-blob {
281 281
282table.bin-blob th { 282table.bin-blob th {
283 font-family: monospace; 283 font-family: monospace;
284 white-space: pre; 284 white-space: pre;
285 border: solid 1px #777; 285 border: solid 1px #777;
286 padding: 0.5em 1em; 286 padding: 0.5em 1em;
287} 287}
288 288
289table.bin-blob td { 289table.bin-blob td {
290 font-family: monospace; 290 font-family: monospace;
291 white-space: pre; 291 white-space: pre;
292 border-left: solid 1px #777; 292 border-left: solid 1px #777;
293 padding: 0em 1em; 293 padding: 0em 1em;
294} 294}
295 295
296table.nowrap td { 296table.nowrap td {
297 white-space: nowrap; 297 white-space: nowrap;
298} 298}
299 299
300table.commit-info { 300table.commit-info {
301 border-collapse: collapse; 301 border-collapse: collapse;
302 margin-top: 1.5em; 302 margin-top: 1.5em;
303} 303}
304 304
305table.commit-info th { 305table.commit-info th {
306 text-align: left; 306 text-align: left;
307 font-weight: normal; 307 font-weight: normal;
308 padding: 0.1em 1em 0.1em 0.1em; 308 padding: 0.1em 1em 0.1em 0.1em;
309 vertical-align: top; 309 vertical-align: top;
310} 310}
311 311
312table.commit-info td { 312table.commit-info td {
313 font-weight: normal; 313 font-weight: normal;
314 padding: 0.1em 1em 0.1em 0.1em; 314 padding: 0.1em 1em 0.1em 0.1em;
315} 315}
316 316
317div.commit-subject { 317div.commit-subject {
318 font-weight: bold; 318 font-weight: bold;
319 font-size: 125%; 319 font-size: 125%;
320 margin: 1.5em 0em 0.5em 0em; 320 margin: 1.5em 0em 0.5em 0em;
321 padding: 0em; 321 padding: 0em;
322} 322}
323 323
324div.commit-msg { 324div.commit-msg {
325 white-space: pre; 325 white-space: pre;
326 font-family: monospace; 326 font-family: monospace;
327} 327}
328 328
329div.notes-header {
330 font-weight: bold;
331 padding-top: 1.5em;
332}
333
334div.notes {
335 white-space: pre;
336 font-family: monospace;
337 border: solid 1px #ee9;
338 background-color: #ffd;
339 padding: 0.3em 2em 0.3em 1em;
340 float: left;
341}
342
343div.notes-footer {
344 clear: left;
345}
346
329div.diffstat-header { 347div.diffstat-header {
330 font-weight: bold; 348 font-weight: bold;
331 padding-top: 1.5em; 349 padding-top: 1.5em;
332} 350}
333 351
334table.diffstat { 352table.diffstat {
335 border-collapse: collapse; 353 border-collapse: collapse;
336 border: solid 1px #aaa; 354 border: solid 1px #aaa;
337 background-color: #eee; 355 background-color: #eee;
338} 356}
339 357
340table.diffstat th { 358table.diffstat th {
341 font-weight: normal; 359 font-weight: normal;
342 text-align: left; 360 text-align: left;
343 text-decoration: underline; 361 text-decoration: underline;
344 padding: 0.1em 1em 0.1em 0.1em; 362 padding: 0.1em 1em 0.1em 0.1em;
345 font-size: 100%; 363 font-size: 100%;
346} 364}
347 365
348table.diffstat td { 366table.diffstat td {
349 padding: 0.2em 0.2em 0.1em 0.1em; 367 padding: 0.2em 0.2em 0.1em 0.1em;
350 font-size: 100%; 368 font-size: 100%;
351 border: none; 369 border: none;
352} 370}
353 371
354table.diffstat td.mode { 372table.diffstat td.mode {
355 white-space: nowrap; 373 white-space: nowrap;
356} 374}
357 375
358table.diffstat td span.modechange { 376table.diffstat td span.modechange {
359 padding-left: 1em; 377 padding-left: 1em;
360 color: red; 378 color: red;
361} 379}
362 380
363table.diffstat td.add a { 381table.diffstat td.add a {
364 color: green; 382 color: green;
365} 383}
366 384
367table.diffstat td.del a { 385table.diffstat td.del a {
368 color: red; 386 color: red;
369} 387}
370 388
371table.diffstat td.upd a { 389table.diffstat td.upd a {
372 color: blue; 390 color: blue;
373} 391}
374 392
375table.diffstat td.graph { 393table.diffstat td.graph {
376 width: 500px; 394 width: 500px;
diff --git a/cgit.h b/cgit.h
index e9e2718..32d9d2b 100644
--- a/cgit.h
+++ b/cgit.h
@@ -1,69 +1,70 @@
1#ifndef CGIT_H 1#ifndef CGIT_H
2#define CGIT_H 2#define CGIT_H
3 3
4 4
5#include <git-compat-util.h> 5#include <git-compat-util.h>
6#include <cache.h> 6#include <cache.h>
7#include <grep.h> 7#include <grep.h>
8#include <object.h> 8#include <object.h>
9#include <tree.h> 9#include <tree.h>
10#include <commit.h> 10#include <commit.h>
11#include <tag.h> 11#include <tag.h>
12#include <diff.h> 12#include <diff.h>
13#include <diffcore.h> 13#include <diffcore.h>
14#include <refs.h> 14#include <refs.h>
15#include <revision.h> 15#include <revision.h>
16#include <log-tree.h> 16#include <log-tree.h>
17#include <archive.h> 17#include <archive.h>
18#include <string-list.h> 18#include <string-list.h>
19#include <xdiff-interface.h> 19#include <xdiff-interface.h>
20#include <xdiff/xdiff.h> 20#include <xdiff/xdiff.h>
21#include <utf8.h> 21#include <utf8.h>
22#include <notes.h>
22 23
23 24
24/* 25/*
25 * Dateformats used on misc. pages 26 * Dateformats used on misc. pages
26 */ 27 */
27#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" 28#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
28#define FMT_SHORTDATE "%Y-%m-%d" 29#define FMT_SHORTDATE "%Y-%m-%d"
29#define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" 30#define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
30 31
31 32
32/* 33/*
33 * Limits used for relative dates 34 * Limits used for relative dates
34 */ 35 */
35#define TM_MIN 60 36#define TM_MIN 60
36#define TM_HOUR (TM_MIN * 60) 37#define TM_HOUR (TM_MIN * 60)
37#define TM_DAY (TM_HOUR * 24) 38#define TM_DAY (TM_HOUR * 24)
38#define TM_WEEK (TM_DAY * 7) 39#define TM_WEEK (TM_DAY * 7)
39#define TM_YEAR (TM_DAY * 365) 40#define TM_YEAR (TM_DAY * 365)
40#define TM_MONTH (TM_YEAR / 12.0) 41#define TM_MONTH (TM_YEAR / 12.0)
41 42
42 43
43/* 44/*
44 * Default encoding 45 * Default encoding
45 */ 46 */
46#define PAGE_ENCODING "UTF-8" 47#define PAGE_ENCODING "UTF-8"
47 48
48typedef void (*configfn)(const char *name, const char *value); 49typedef void (*configfn)(const char *name, const char *value);
49typedef void (*filepair_fn)(struct diff_filepair *pair); 50typedef void (*filepair_fn)(struct diff_filepair *pair);
50typedef void (*linediff_fn)(char *line, int len); 51typedef void (*linediff_fn)(char *line, int len);
51 52
52struct cgit_filter { 53struct cgit_filter {
53 char *cmd; 54 char *cmd;
54 char **argv; 55 char **argv;
55 int old_stdout; 56 int old_stdout;
56 int pipe_fh[2]; 57 int pipe_fh[2];
57 int pid; 58 int pid;
58 int exitstatus; 59 int exitstatus;
59}; 60};
60 61
61struct cgit_repo { 62struct cgit_repo {
62 char *url; 63 char *url;
63 char *name; 64 char *name;
64 char *path; 65 char *path;
65 char *desc; 66 char *desc;
66 char *owner; 67 char *owner;
67 char *defbranch; 68 char *defbranch;
68 char *module_link; 69 char *module_link;
69 char *readme; 70 char *readme;
diff --git a/ui-commit.c b/ui-commit.c
index a11bc5f..45af450 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -1,131 +1,146 @@
1/* ui-commit.c: generate commit view 1/* ui-commit.c: generate commit view
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include "html.h" 10#include "html.h"
11#include "ui-shared.h" 11#include "ui-shared.h"
12#include "ui-diff.h" 12#include "ui-diff.h"
13#include "ui-log.h" 13#include "ui-log.h"
14 14
15void cgit_print_commit(char *hex, const char *prefix) 15void cgit_print_commit(char *hex, const char *prefix)
16{ 16{
17 struct commit *commit, *parent; 17 struct commit *commit, *parent;
18 struct commitinfo *info, *parent_info; 18 struct commitinfo *info, *parent_info;
19 struct commit_list *p; 19 struct commit_list *p;
20 struct strbuf notes = STRBUF_INIT;
20 unsigned char sha1[20]; 21 unsigned char sha1[20];
21 char *tmp, *tmp2; 22 char *tmp, *tmp2;
22 int parents = 0; 23 int parents = 0;
23 24
24 if (!hex) 25 if (!hex)
25 hex = ctx.qry.head; 26 hex = ctx.qry.head;
26 27
27 if (get_sha1(hex, sha1)) { 28 if (get_sha1(hex, sha1)) {
28 cgit_print_error(fmt("Bad object id: %s", hex)); 29 cgit_print_error(fmt("Bad object id: %s", hex));
29 return; 30 return;
30 } 31 }
31 commit = lookup_commit_reference(sha1); 32 commit = lookup_commit_reference(sha1);
32 if (!commit) { 33 if (!commit) {
33 cgit_print_error(fmt("Bad commit reference: %s", hex)); 34 cgit_print_error(fmt("Bad commit reference: %s", hex));
34 return; 35 return;
35 } 36 }
36 info = cgit_parse_commit(commit); 37 info = cgit_parse_commit(commit);
37 38
39 get_commit_notes(commit, &notes, PAGE_ENCODING, 0);
40
38 load_ref_decorations(DECORATE_FULL_REFS); 41 load_ref_decorations(DECORATE_FULL_REFS);
39 42
40 html("<table summary='commit info' class='commit-info'>\n"); 43 html("<table summary='commit info' class='commit-info'>\n");
41 html("<tr><th>author</th><td>"); 44 html("<tr><th>author</th><td>");
42 html_txt(info->author); 45 html_txt(info->author);
43 if (!ctx.cfg.noplainemail) { 46 if (!ctx.cfg.noplainemail) {
44 html(" "); 47 html(" ");
45 html_txt(info->author_email); 48 html_txt(info->author_email);
46 } 49 }
47 html("</td><td class='right'>"); 50 html("</td><td class='right'>");
48 cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time); 51 cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
49 html("</td></tr>\n"); 52 html("</td></tr>\n");
50 html("<tr><th>committer</th><td>"); 53 html("<tr><th>committer</th><td>");
51 html_txt(info->committer); 54 html_txt(info->committer);
52 if (!ctx.cfg.noplainemail) { 55 if (!ctx.cfg.noplainemail) {
53 html(" "); 56 html(" ");
54 html_txt(info->committer_email); 57 html_txt(info->committer_email);
55 } 58 }
56 html("</td><td class='right'>"); 59 html("</td><td class='right'>");
57 cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time); 60 cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
58 html("</td></tr>\n"); 61 html("</td></tr>\n");
59 html("<tr><th>commit</th><td colspan='2' class='sha1'>"); 62 html("<tr><th>commit</th><td colspan='2' class='sha1'>");
60 tmp = sha1_to_hex(commit->object.sha1); 63 tmp = sha1_to_hex(commit->object.sha1);
61 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0); 64 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
62 html(" ("); 65 html(" (");
63 cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix); 66 cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
64 html(") ("); 67 html(") (");
65 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) 68 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
66 cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1); 69 cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
67 else 70 else
68 cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1); 71 cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
69 html(")</td></tr>\n"); 72 html(")</td></tr>\n");
70 html("<tr><th>tree</th><td colspan='2' class='sha1'>"); 73 html("<tr><th>tree</th><td colspan='2' class='sha1'>");
71 tmp = xstrdup(hex); 74 tmp = xstrdup(hex);
72 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, 75 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
73 ctx.qry.head, tmp, NULL); 76 ctx.qry.head, tmp, NULL);
74 if (prefix) { 77 if (prefix) {
75 html(" /"); 78 html(" /");
76 cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix); 79 cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix);
77 } 80 }
78 html("</td></tr>\n"); 81 html("</td></tr>\n");
79 for (p = commit->parents; p ; p = p->next) { 82 for (p = commit->parents; p ; p = p->next) {
80 parent = lookup_commit_reference(p->item->object.sha1); 83 parent = lookup_commit_reference(p->item->object.sha1);
81 if (!parent) { 84 if (!parent) {
82 html("<tr><td colspan='3'>"); 85 html("<tr><td colspan='3'>");
83 cgit_print_error("Error reading parent commit"); 86 cgit_print_error("Error reading parent commit");
84 html("</td></tr>"); 87 html("</td></tr>");
85 continue; 88 continue;
86 } 89 }
87 html("<tr><th>parent</th>" 90 html("<tr><th>parent</th>"
88 "<td colspan='2' class='sha1'>"); 91 "<td colspan='2' class='sha1'>");
89 tmp = tmp2 = sha1_to_hex(p->item->object.sha1); 92 tmp = tmp2 = sha1_to_hex(p->item->object.sha1);
90 if (ctx.repo->enable_subject_links) { 93 if (ctx.repo->enable_subject_links) {
91 parent_info = cgit_parse_commit(parent); 94 parent_info = cgit_parse_commit(parent);
92 tmp2 = parent_info->subject; 95 tmp2 = parent_info->subject;
93 } 96 }
94 cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0); 97 cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
95 html(" ("); 98 html(" (");
96 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, 99 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
97 sha1_to_hex(p->item->object.sha1), prefix, 0); 100 sha1_to_hex(p->item->object.sha1), prefix, 0);
98 html(")</td></tr>"); 101 html(")</td></tr>");
99 parents++; 102 parents++;
100 } 103 }
101 if (ctx.repo->snapshots) { 104 if (ctx.repo->snapshots) {
102 html("<tr><th>download</th><td colspan='2' class='sha1'>"); 105 html("<tr><th>download</th><td colspan='2' class='sha1'>");
103 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, 106 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
104 hex, ctx.repo->snapshots); 107 hex, ctx.repo->snapshots);
105 html("</td></tr>"); 108 html("</td></tr>");
106 } 109 }
107 html("</table>\n"); 110 html("</table>\n");
108 html("<div class='commit-subject'>"); 111 html("<div class='commit-subject'>");
109 if (ctx.repo->commit_filter) 112 if (ctx.repo->commit_filter)
110 cgit_open_filter(ctx.repo->commit_filter); 113 cgit_open_filter(ctx.repo->commit_filter);
111 html_txt(info->subject); 114 html_txt(info->subject);
112 if (ctx.repo->commit_filter) 115 if (ctx.repo->commit_filter)
113 cgit_close_filter(ctx.repo->commit_filter); 116 cgit_close_filter(ctx.repo->commit_filter);
114 show_commit_decorations(commit); 117 show_commit_decorations(commit);
115 html("</div>"); 118 html("</div>");
116 html("<div class='commit-msg'>"); 119 html("<div class='commit-msg'>");
117 if (ctx.repo->commit_filter) 120 if (ctx.repo->commit_filter)
118 cgit_open_filter(ctx.repo->commit_filter); 121 cgit_open_filter(ctx.repo->commit_filter);
119 html_txt(info->msg); 122 html_txt(info->msg);
120 if (ctx.repo->commit_filter) 123 if (ctx.repo->commit_filter)
121 cgit_close_filter(ctx.repo->commit_filter); 124 cgit_close_filter(ctx.repo->commit_filter);
122 html("</div>"); 125 html("</div>");
126 if (notes.len != 0) {
127 html("<div class='notes-header'>Notes</div>");
128 html("<div class='notes'>");
129 if (ctx.repo->commit_filter)
130 cgit_open_filter(ctx.repo->commit_filter);
131 html_txt(notes.buf);
132 if (ctx.repo->commit_filter)
133 cgit_close_filter(ctx.repo->commit_filter);
134 html("</div>");
135 html("<div class='notes-footer'></div>");
136 }
123 if (parents < 3) { 137 if (parents < 3) {
124 if (parents) 138 if (parents)
125 tmp = sha1_to_hex(commit->parents->item->object.sha1); 139 tmp = sha1_to_hex(commit->parents->item->object.sha1);
126 else 140 else
127 tmp = NULL; 141 tmp = NULL;
128 cgit_print_diff(ctx.qry.sha1, tmp, prefix); 142 cgit_print_diff(ctx.qry.sha1, tmp, prefix);
129 } 143 }
144 strbuf_release(&notes);
130 cgit_free_commitinfo(info); 145 cgit_free_commitinfo(info);
131} 146}