summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2010-08-04 01:10:24 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-08-04 01:10:24 (UTC)
commite6c960c7c0f0d2e54b51cc43ef190df3ce52755e (patch) (unidiff)
tree29b49ca32a3de23b58ef5c2b7e522b607b60f356
parent6a8f65bf184d85a0c51ffecca16f48e6f4b1ff12 (diff)
parent39c2e224d3c55dfa1a7668399897be295be07dc7 (diff)
downloadcgit-e6c960c7c0f0d2e54b51cc43ef190df3ce52755e.zip
cgit-e6c960c7c0f0d2e54b51cc43ef190df3ce52755e.tar.gz
cgit-e6c960c7c0f0d2e54b51cc43ef190df3ce52755e.tar.bz2
Merge branch 'js/notes'
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.css29
-rw-r--r--cgit.h1
-rw-r--r--ui-commit.c15
-rw-r--r--ui-log.c12
4 files changed, 57 insertions, 0 deletions
diff --git a/cgit.css b/cgit.css
index 6e47eb3..0c88b65 100644
--- a/cgit.css
+++ b/cgit.css
@@ -71,354 +71,383 @@ table.tabs {
71 width: 100%; 71 width: 100%;
72} 72}
73 73
74table.tabs td { 74table.tabs td {
75 padding: 0px 1em; 75 padding: 0px 1em;
76 vertical-align: bottom; 76 vertical-align: bottom;
77} 77}
78 78
79table.tabs td a { 79table.tabs td a {
80 padding: 2px 0.75em; 80 padding: 2px 0.75em;
81 color: #777; 81 color: #777;
82 font-size: 110%; 82 font-size: 110%;
83} 83}
84 84
85table.tabs td a.active { 85table.tabs td a.active {
86 color: #000; 86 color: #000;
87 background-color: #ccc; 87 background-color: #ccc;
88} 88}
89 89
90table.tabs td.form { 90table.tabs td.form {
91 text-align: right; 91 text-align: right;
92} 92}
93 93
94table.tabs td.form form { 94table.tabs td.form form {
95 padding-bottom: 2px; 95 padding-bottom: 2px;
96 font-size: 90%; 96 font-size: 90%;
97 white-space: nowrap; 97 white-space: nowrap;
98} 98}
99 99
100table.tabs td.form input, 100table.tabs td.form input,
101table.tabs td.form select { 101table.tabs td.form select {
102 font-size: 90%; 102 font-size: 90%;
103} 103}
104 104
105div.path { 105div.path {
106 margin: 0px; 106 margin: 0px;
107 padding: 5px 2em 2px 2em; 107 padding: 5px 2em 2px 2em;
108 color: #000; 108 color: #000;
109 background-color: #eee; 109 background-color: #eee;
110} 110}
111 111
112div.content { 112div.content {
113 margin: 0px; 113 margin: 0px;
114 padding: 2em; 114 padding: 2em;
115 border-bottom: solid 3px #ccc; 115 border-bottom: solid 3px #ccc;
116} 116}
117 117
118 118
119table.list { 119table.list {
120 width: 100%; 120 width: 100%;
121 border: none; 121 border: none;
122 border-collapse: collapse; 122 border-collapse: collapse;
123} 123}
124 124
125table.list tr { 125table.list tr {
126 background: white; 126 background: white;
127} 127}
128 128
129table.list tr.logheader { 129table.list tr.logheader {
130 background: #eee; 130 background: #eee;
131} 131}
132 132
133table.list tr:hover { 133table.list tr:hover {
134 background: #eee; 134 background: #eee;
135} 135}
136 136
137table.list tr.nohover:hover { 137table.list tr.nohover:hover {
138 background: white; 138 background: white;
139} 139}
140 140
141table.list th { 141table.list th {
142 font-weight: bold; 142 font-weight: bold;
143 /* color: #888; 143 /* color: #888;
144 border-top: dashed 1px #888; 144 border-top: dashed 1px #888;
145 border-bottom: dashed 1px #888; 145 border-bottom: dashed 1px #888;
146 */ 146 */
147 padding: 0.1em 0.5em 0.05em 0.5em; 147 padding: 0.1em 0.5em 0.05em 0.5em;
148 vertical-align: baseline; 148 vertical-align: baseline;
149} 149}
150 150
151table.list td { 151table.list td {
152 border: none; 152 border: none;
153 padding: 0.1em 0.5em 0.1em 0.5em; 153 padding: 0.1em 0.5em 0.1em 0.5em;
154} 154}
155 155
156table.list td.logsubject { 156table.list td.logsubject {
157 font-family: monospace; 157 font-family: monospace;
158 font-weight: bold; 158 font-weight: bold;
159} 159}
160 160
161table.list td.logmsg { 161table.list td.logmsg {
162 font-family: monospace; 162 font-family: monospace;
163 white-space: pre; 163 white-space: pre;
164 padding: 1em 0.5em 2em 0.5em; 164 padding: 1em 0.5em 2em 0.5em;
165} 165}
166 166
167table.list td.lognotes-label {
168 text-align:right;
169 vertical-align:top;
170}
171
172table.list td.lognotes {
173 font-family: monospace;
174 white-space: pre;
175 padding: 0em 0.5em 2em 0.5em;
176}
177
167table.list td a { 178table.list td a {
168 color: black; 179 color: black;
169} 180}
170 181
171table.list td a.ls-dir { 182table.list td a.ls-dir {
172 font-weight: bold; 183 font-weight: bold;
173 color: #00f; 184 color: #00f;
174} 185}
175 186
176table.list td a:hover { 187table.list td a:hover {
177 color: #00f; 188 color: #00f;
178} 189}
179 190
180img { 191img {
181 border: none; 192 border: none;
182} 193}
183 194
184input#switch-btn { 195input#switch-btn {
185 margin: 2px 0px 0px 0px; 196 margin: 2px 0px 0px 0px;
186} 197}
187 198
188td#sidebar input.txt { 199td#sidebar input.txt {
189 width: 100%; 200 width: 100%;
190 margin: 2px 0px 0px 0px; 201 margin: 2px 0px 0px 0px;
191} 202}
192 203
193table#grid { 204table#grid {
194 margin: 0px; 205 margin: 0px;
195} 206}
196 207
197td#content { 208td#content {
198 vertical-align: top; 209 vertical-align: top;
199 padding: 1em 2em 1em 1em; 210 padding: 1em 2em 1em 1em;
200 border: none; 211 border: none;
201} 212}
202 213
203div#summary { 214div#summary {
204 vertical-align: top; 215 vertical-align: top;
205 margin-bottom: 1em; 216 margin-bottom: 1em;
206} 217}
207 218
208table#downloads { 219table#downloads {
209 float: right; 220 float: right;
210 border-collapse: collapse; 221 border-collapse: collapse;
211 border: solid 1px #777; 222 border: solid 1px #777;
212 margin-left: 0.5em; 223 margin-left: 0.5em;
213 margin-bottom: 0.5em; 224 margin-bottom: 0.5em;
214} 225}
215 226
216table#downloads th { 227table#downloads th {
217 background-color: #ccc; 228 background-color: #ccc;
218} 229}
219 230
220div#blob { 231div#blob {
221 border: solid 1px black; 232 border: solid 1px black;
222} 233}
223 234
224div.error { 235div.error {
225 color: red; 236 color: red;
226 font-weight: bold; 237 font-weight: bold;
227 margin: 1em 2em; 238 margin: 1em 2em;
228} 239}
229 240
230a.ls-blob, a.ls-dir, a.ls-mod { 241a.ls-blob, a.ls-dir, a.ls-mod {
231 font-family: monospace; 242 font-family: monospace;
232} 243}
233 244
234td.ls-size { 245td.ls-size {
235 text-align: right; 246 text-align: right;
236 font-family: monospace; 247 font-family: monospace;
237 width: 10em; 248 width: 10em;
238} 249}
239 250
240td.ls-mode { 251td.ls-mode {
241 font-family: monospace; 252 font-family: monospace;
242 width: 10em; 253 width: 10em;
243} 254}
244 255
245table.blob { 256table.blob {
246 margin-top: 0.5em; 257 margin-top: 0.5em;
247 border-top: solid 1px black; 258 border-top: solid 1px black;
248} 259}
249 260
250table.blob td.lines { 261table.blob td.lines {
251 margin: 0; padding: 0 0 0 0.5em; 262 margin: 0; padding: 0 0 0 0.5em;
252 vertical-align: top; 263 vertical-align: top;
253 color: black; 264 color: black;
254} 265}
255 266
256table.blob td.linenumbers { 267table.blob td.linenumbers {
257 margin: 0; padding: 0 0.5em 0 0.5em; 268 margin: 0; padding: 0 0.5em 0 0.5em;
258 vertical-align: top; 269 vertical-align: top;
259 text-align: right; 270 text-align: right;
260 border-right: 1px solid gray; 271 border-right: 1px solid gray;
261} 272}
262 273
263table.blob pre { 274table.blob pre {
264 padding: 0; margin: 0; 275 padding: 0; margin: 0;
265} 276}
266 277
267table.blob a.no { 278table.blob a.no {
268 color: gray; 279 color: gray;
269 text-align: right; 280 text-align: right;
270 text-decoration: none; 281 text-decoration: none;
271} 282}
272 283
273table.blob a.no a:hover { 284table.blob a.no a:hover {
274 color: black; 285 color: black;
275} 286}
276 287
277table.bin-blob { 288table.bin-blob {
278 margin-top: 0.5em; 289 margin-top: 0.5em;
279 border: solid 1px black; 290 border: solid 1px black;
280} 291}
281 292
282table.bin-blob th { 293table.bin-blob th {
283 font-family: monospace; 294 font-family: monospace;
284 white-space: pre; 295 white-space: pre;
285 border: solid 1px #777; 296 border: solid 1px #777;
286 padding: 0.5em 1em; 297 padding: 0.5em 1em;
287} 298}
288 299
289table.bin-blob td { 300table.bin-blob td {
290 font-family: monospace; 301 font-family: monospace;
291 white-space: pre; 302 white-space: pre;
292 border-left: solid 1px #777; 303 border-left: solid 1px #777;
293 padding: 0em 1em; 304 padding: 0em 1em;
294} 305}
295 306
296table.nowrap td { 307table.nowrap td {
297 white-space: nowrap; 308 white-space: nowrap;
298} 309}
299 310
300table.commit-info { 311table.commit-info {
301 border-collapse: collapse; 312 border-collapse: collapse;
302 margin-top: 1.5em; 313 margin-top: 1.5em;
303} 314}
304 315
305table.commit-info th { 316table.commit-info th {
306 text-align: left; 317 text-align: left;
307 font-weight: normal; 318 font-weight: normal;
308 padding: 0.1em 1em 0.1em 0.1em; 319 padding: 0.1em 1em 0.1em 0.1em;
309 vertical-align: top; 320 vertical-align: top;
310} 321}
311 322
312table.commit-info td { 323table.commit-info td {
313 font-weight: normal; 324 font-weight: normal;
314 padding: 0.1em 1em 0.1em 0.1em; 325 padding: 0.1em 1em 0.1em 0.1em;
315} 326}
316 327
317div.commit-subject { 328div.commit-subject {
318 font-weight: bold; 329 font-weight: bold;
319 font-size: 125%; 330 font-size: 125%;
320 margin: 1.5em 0em 0.5em 0em; 331 margin: 1.5em 0em 0.5em 0em;
321 padding: 0em; 332 padding: 0em;
322} 333}
323 334
324div.commit-msg { 335div.commit-msg {
325 white-space: pre; 336 white-space: pre;
326 font-family: monospace; 337 font-family: monospace;
327} 338}
328 339
340div.notes-header {
341 font-weight: bold;
342 padding-top: 1.5em;
343}
344
345div.notes {
346 white-space: pre;
347 font-family: monospace;
348 border: solid 1px #ee9;
349 background-color: #ffd;
350 padding: 0.3em 2em 0.3em 1em;
351 float: left;
352}
353
354div.notes-footer {
355 clear: left;
356}
357
329div.diffstat-header { 358div.diffstat-header {
330 font-weight: bold; 359 font-weight: bold;
331 padding-top: 1.5em; 360 padding-top: 1.5em;
332} 361}
333 362
334table.diffstat { 363table.diffstat {
335 border-collapse: collapse; 364 border-collapse: collapse;
336 border: solid 1px #aaa; 365 border: solid 1px #aaa;
337 background-color: #eee; 366 background-color: #eee;
338} 367}
339 368
340table.diffstat th { 369table.diffstat th {
341 font-weight: normal; 370 font-weight: normal;
342 text-align: left; 371 text-align: left;
343 text-decoration: underline; 372 text-decoration: underline;
344 padding: 0.1em 1em 0.1em 0.1em; 373 padding: 0.1em 1em 0.1em 0.1em;
345 font-size: 100%; 374 font-size: 100%;
346} 375}
347 376
348table.diffstat td { 377table.diffstat td {
349 padding: 0.2em 0.2em 0.1em 0.1em; 378 padding: 0.2em 0.2em 0.1em 0.1em;
350 font-size: 100%; 379 font-size: 100%;
351 border: none; 380 border: none;
352} 381}
353 382
354table.diffstat td.mode { 383table.diffstat td.mode {
355 white-space: nowrap; 384 white-space: nowrap;
356} 385}
357 386
358table.diffstat td span.modechange { 387table.diffstat td span.modechange {
359 padding-left: 1em; 388 padding-left: 1em;
360 color: red; 389 color: red;
361} 390}
362 391
363table.diffstat td.add a { 392table.diffstat td.add a {
364 color: green; 393 color: green;
365} 394}
366 395
367table.diffstat td.del a { 396table.diffstat td.del a {
368 color: red; 397 color: red;
369} 398}
370 399
371table.diffstat td.upd a { 400table.diffstat td.upd a {
372 color: blue; 401 color: blue;
373} 402}
374 403
375table.diffstat td.graph { 404table.diffstat td.graph {
376 width: 500px; 405 width: 500px;
377 vertical-align: middle; 406 vertical-align: middle;
378} 407}
379 408
380table.diffstat td.graph table { 409table.diffstat td.graph table {
381 border: none; 410 border: none;
382} 411}
383 412
384table.diffstat td.graph td { 413table.diffstat td.graph td {
385 padding: 0px; 414 padding: 0px;
386 border: 0px; 415 border: 0px;
387 height: 7pt; 416 height: 7pt;
388} 417}
389 418
390table.diffstat td.graph td.add { 419table.diffstat td.graph td.add {
391 background-color: #5c5; 420 background-color: #5c5;
392} 421}
393 422
394table.diffstat td.graph td.rem { 423table.diffstat td.graph td.rem {
395 background-color: #c55; 424 background-color: #c55;
396} 425}
397 426
398div.diffstat-summary { 427div.diffstat-summary {
399 color: #888; 428 color: #888;
400 padding-top: 0.5em; 429 padding-top: 0.5em;
401} 430}
402 431
403table.diff { 432table.diff {
404 width: 100%; 433 width: 100%;
405} 434}
406 435
407table.diff td { 436table.diff td {
408 font-family: monospace; 437 font-family: monospace;
409 white-space: pre; 438 white-space: pre;
410} 439}
411 440
412table.diff td div.head { 441table.diff td div.head {
413 font-weight: bold; 442 font-weight: bold;
414 margin-top: 1em; 443 margin-top: 1em;
415 color: black; 444 color: black;
416} 445}
417 446
418table.diff td div.hunk { 447table.diff td div.hunk {
419 color: #009; 448 color: #009;
420} 449}
421 450
422table.diff td div.add { 451table.diff td div.add {
423 color: green; 452 color: green;
424} 453}
diff --git a/cgit.h b/cgit.h
index e9e2718..32d9d2b 100644
--- a/cgit.h
+++ b/cgit.h
@@ -1,117 +1,118 @@
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;
70 char *section; 71 char *section;
71 char *clone_url; 72 char *clone_url;
72 int snapshots; 73 int snapshots;
73 int enable_log_filecount; 74 int enable_log_filecount;
74 int enable_log_linecount; 75 int enable_log_linecount;
75 int enable_remote_branches; 76 int enable_remote_branches;
76 int enable_subject_links; 77 int enable_subject_links;
77 int max_stats; 78 int max_stats;
78 time_t mtime; 79 time_t mtime;
79 struct cgit_filter *about_filter; 80 struct cgit_filter *about_filter;
80 struct cgit_filter *commit_filter; 81 struct cgit_filter *commit_filter;
81 struct cgit_filter *source_filter; 82 struct cgit_filter *source_filter;
82}; 83};
83 84
84typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, 85typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,
85 const char *value); 86 const char *value);
86 87
87struct cgit_repolist { 88struct cgit_repolist {
88 int length; 89 int length;
89 int count; 90 int count;
90 struct cgit_repo *repos; 91 struct cgit_repo *repos;
91}; 92};
92 93
93struct commitinfo { 94struct commitinfo {
94 struct commit *commit; 95 struct commit *commit;
95 char *author; 96 char *author;
96 char *author_email; 97 char *author_email;
97 unsigned long author_date; 98 unsigned long author_date;
98 char *committer; 99 char *committer;
99 char *committer_email; 100 char *committer_email;
100 unsigned long committer_date; 101 unsigned long committer_date;
101 char *subject; 102 char *subject;
102 char *msg; 103 char *msg;
103 char *msg_encoding; 104 char *msg_encoding;
104}; 105};
105 106
106struct taginfo { 107struct taginfo {
107 char *tagger; 108 char *tagger;
108 char *tagger_email; 109 char *tagger_email;
109 unsigned long tagger_date; 110 unsigned long tagger_date;
110 char *msg; 111 char *msg;
111}; 112};
112 113
113struct refinfo { 114struct refinfo {
114 const char *refname; 115 const char *refname;
115 struct object *object; 116 struct object *object;
116 union { 117 union {
117 struct taginfo *tag; 118 struct taginfo *tag;
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}
diff --git a/ui-log.c b/ui-log.c
index ee93653..7f38d2a 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -18,201 +18,213 @@ void count_lines(char *line, int size)
18 return; 18 return;
19 19
20 if (line[0] == '+') 20 if (line[0] == '+')
21 add_lines++; 21 add_lines++;
22 22
23 else if (line[0] == '-') 23 else if (line[0] == '-')
24 rem_lines++; 24 rem_lines++;
25} 25}
26 26
27void inspect_files(struct diff_filepair *pair) 27void inspect_files(struct diff_filepair *pair)
28{ 28{
29 unsigned long old_size = 0; 29 unsigned long old_size = 0;
30 unsigned long new_size = 0; 30 unsigned long new_size = 0;
31 int binary = 0; 31 int binary = 0;
32 32
33 files++; 33 files++;
34 if (ctx.repo->enable_log_linecount) 34 if (ctx.repo->enable_log_linecount)
35 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, 35 cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size,
36 &new_size, &binary, 0, ctx.qry.ignorews, 36 &new_size, &binary, 0, ctx.qry.ignorews,
37 count_lines); 37 count_lines);
38} 38}
39 39
40void show_commit_decorations(struct commit *commit) 40void show_commit_decorations(struct commit *commit)
41{ 41{
42 struct name_decoration *deco; 42 struct name_decoration *deco;
43 static char buf[1024]; 43 static char buf[1024];
44 44
45 buf[sizeof(buf) - 1] = 0; 45 buf[sizeof(buf) - 1] = 0;
46 deco = lookup_decoration(&name_decoration, &commit->object); 46 deco = lookup_decoration(&name_decoration, &commit->object);
47 while (deco) { 47 while (deco) {
48 if (!prefixcmp(deco->name, "refs/heads/")) { 48 if (!prefixcmp(deco->name, "refs/heads/")) {
49 strncpy(buf, deco->name + 11, sizeof(buf) - 1); 49 strncpy(buf, deco->name + 11, sizeof(buf) - 1);
50 cgit_log_link(buf, NULL, "branch-deco", buf, NULL, 50 cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
51 ctx.qry.vpath, 0, NULL, NULL, 51 ctx.qry.vpath, 0, NULL, NULL,
52 ctx.qry.showmsg); 52 ctx.qry.showmsg);
53 } 53 }
54 else if (!prefixcmp(deco->name, "tag: refs/tags/")) { 54 else if (!prefixcmp(deco->name, "tag: refs/tags/")) {
55 strncpy(buf, deco->name + 15, sizeof(buf) - 1); 55 strncpy(buf, deco->name + 15, sizeof(buf) - 1);
56 cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); 56 cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);
57 } 57 }
58 else if (!prefixcmp(deco->name, "refs/tags/")) { 58 else if (!prefixcmp(deco->name, "refs/tags/")) {
59 strncpy(buf, deco->name + 10, sizeof(buf) - 1); 59 strncpy(buf, deco->name + 10, sizeof(buf) - 1);
60 cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); 60 cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);
61 } 61 }
62 else if (!prefixcmp(deco->name, "refs/remotes/")) { 62 else if (!prefixcmp(deco->name, "refs/remotes/")) {
63 strncpy(buf, deco->name + 13, sizeof(buf) - 1); 63 strncpy(buf, deco->name + 13, sizeof(buf) - 1);
64 cgit_log_link(buf, NULL, "remote-deco", NULL, 64 cgit_log_link(buf, NULL, "remote-deco", NULL,
65 sha1_to_hex(commit->object.sha1), 65 sha1_to_hex(commit->object.sha1),
66 ctx.qry.vpath, 0, NULL, NULL, 66 ctx.qry.vpath, 0, NULL, NULL,
67 ctx.qry.showmsg); 67 ctx.qry.showmsg);
68 } 68 }
69 else { 69 else {
70 strncpy(buf, deco->name, sizeof(buf) - 1); 70 strncpy(buf, deco->name, sizeof(buf) - 1);
71 cgit_commit_link(buf, NULL, "deco", ctx.qry.head, 71 cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
72 sha1_to_hex(commit->object.sha1), 72 sha1_to_hex(commit->object.sha1),
73 ctx.qry.vpath, 0); 73 ctx.qry.vpath, 0);
74 } 74 }
75 deco = deco->next; 75 deco = deco->next;
76 } 76 }
77} 77}
78 78
79void print_commit(struct commit *commit) 79void print_commit(struct commit *commit)
80{ 80{
81 struct commitinfo *info; 81 struct commitinfo *info;
82 char *tmp; 82 char *tmp;
83 int cols = 2; 83 int cols = 2;
84 84
85 info = cgit_parse_commit(commit); 85 info = cgit_parse_commit(commit);
86 htmlf("<tr%s><td>", 86 htmlf("<tr%s><td>",
87 ctx.qry.showmsg ? " class='logheader'" : ""); 87 ctx.qry.showmsg ? " class='logheader'" : "");
88 tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); 88 tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1));
89 tmp = cgit_fileurl(ctx.repo->url, "commit", ctx.qry.vpath, tmp); 89 tmp = cgit_fileurl(ctx.repo->url, "commit", ctx.qry.vpath, tmp);
90 html_link_open(tmp, NULL, NULL); 90 html_link_open(tmp, NULL, NULL);
91 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); 91 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
92 html_link_close(); 92 html_link_close();
93 htmlf("</td><td%s>", 93 htmlf("</td><td%s>",
94 ctx.qry.showmsg ? " class='logsubject'" : ""); 94 ctx.qry.showmsg ? " class='logsubject'" : "");
95 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, 95 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
96 sha1_to_hex(commit->object.sha1), ctx.qry.vpath, 0); 96 sha1_to_hex(commit->object.sha1), ctx.qry.vpath, 0);
97 show_commit_decorations(commit); 97 show_commit_decorations(commit);
98 html("</td><td>"); 98 html("</td><td>");
99 html_txt(info->author); 99 html_txt(info->author);
100 if (ctx.repo->enable_log_filecount) { 100 if (ctx.repo->enable_log_filecount) {
101 files = 0; 101 files = 0;
102 add_lines = 0; 102 add_lines = 0;
103 rem_lines = 0; 103 rem_lines = 0;
104 cgit_diff_commit(commit, inspect_files); 104 cgit_diff_commit(commit, inspect_files);
105 html("</td><td>"); 105 html("</td><td>");
106 htmlf("%d", files); 106 htmlf("%d", files);
107 if (ctx.repo->enable_log_linecount) { 107 if (ctx.repo->enable_log_linecount) {
108 html("</td><td>"); 108 html("</td><td>");
109 htmlf("-%d/+%d", rem_lines, add_lines); 109 htmlf("-%d/+%d", rem_lines, add_lines);
110 } 110 }
111 } 111 }
112 html("</td></tr>\n"); 112 html("</td></tr>\n");
113 if (ctx.qry.showmsg) { 113 if (ctx.qry.showmsg) {
114 struct strbuf notes = STRBUF_INIT;
115 get_commit_notes(commit, &notes, PAGE_ENCODING, 0);
116
114 if (ctx.repo->enable_log_filecount) { 117 if (ctx.repo->enable_log_filecount) {
115 cols++; 118 cols++;
116 if (ctx.repo->enable_log_linecount) 119 if (ctx.repo->enable_log_linecount)
117 cols++; 120 cols++;
118 } 121 }
119 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>", 122 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>",
120 cols); 123 cols);
121 html_txt(info->msg); 124 html_txt(info->msg);
122 html("</td></tr>\n"); 125 html("</td></tr>\n");
126 if (notes.len != 0) {
127 html("<tr class='nohover'>");
128 html("<td class='lognotes-label'>Notes:</td>");
129 htmlf("<td colspan='%d' class='lognotes'>",
130 cols);
131 html_txt(notes.buf);
132 html("</td></tr>\n");
133 }
134 strbuf_release(&notes);
123 } 135 }
124 cgit_free_commitinfo(info); 136 cgit_free_commitinfo(info);
125} 137}
126 138
127static const char *disambiguate_ref(const char *ref) 139static const char *disambiguate_ref(const char *ref)
128{ 140{
129 unsigned char sha1[20]; 141 unsigned char sha1[20];
130 const char *longref; 142 const char *longref;
131 143
132 longref = fmt("refs/heads/%s", ref); 144 longref = fmt("refs/heads/%s", ref);
133 if (get_sha1(longref, sha1) == 0) 145 if (get_sha1(longref, sha1) == 0)
134 return longref; 146 return longref;
135 147
136 return ref; 148 return ref;
137} 149}
138 150
139void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, 151void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
140 char *path, int pager) 152 char *path, int pager)
141{ 153{
142 struct rev_info rev; 154 struct rev_info rev;
143 struct commit *commit; 155 struct commit *commit;
144 const char *argv[] = {NULL, NULL, NULL, NULL, NULL}; 156 const char *argv[] = {NULL, NULL, NULL, NULL, NULL};
145 int argc = 2; 157 int argc = 2;
146 int i, columns = 3; 158 int i, columns = 3;
147 159
148 if (!tip) 160 if (!tip)
149 tip = ctx.qry.head; 161 tip = ctx.qry.head;
150 162
151 argv[1] = disambiguate_ref(tip); 163 argv[1] = disambiguate_ref(tip);
152 164
153 if (grep && pattern) { 165 if (grep && pattern) {
154 if (!strcmp(grep, "grep") || !strcmp(grep, "author") || 166 if (!strcmp(grep, "grep") || !strcmp(grep, "author") ||
155 !strcmp(grep, "committer")) 167 !strcmp(grep, "committer"))
156 argv[argc++] = fmt("--%s=%s", grep, pattern); 168 argv[argc++] = fmt("--%s=%s", grep, pattern);
157 if (!strcmp(grep, "range")) 169 if (!strcmp(grep, "range"))
158 argv[1] = pattern; 170 argv[1] = pattern;
159 } 171 }
160 172
161 if (path) { 173 if (path) {
162 argv[argc++] = "--"; 174 argv[argc++] = "--";
163 argv[argc++] = path; 175 argv[argc++] = path;
164 } 176 }
165 init_revisions(&rev, NULL); 177 init_revisions(&rev, NULL);
166 rev.abbrev = DEFAULT_ABBREV; 178 rev.abbrev = DEFAULT_ABBREV;
167 rev.commit_format = CMIT_FMT_DEFAULT; 179 rev.commit_format = CMIT_FMT_DEFAULT;
168 rev.verbose_header = 1; 180 rev.verbose_header = 1;
169 rev.show_root_diff = 0; 181 rev.show_root_diff = 0;
170 setup_revisions(argc, argv, &rev, NULL); 182 setup_revisions(argc, argv, &rev, NULL);
171 load_ref_decorations(DECORATE_FULL_REFS); 183 load_ref_decorations(DECORATE_FULL_REFS);
172 rev.show_decorations = 1; 184 rev.show_decorations = 1;
173 rev.grep_filter.regflags |= REG_ICASE; 185 rev.grep_filter.regflags |= REG_ICASE;
174 compile_grep_patterns(&rev.grep_filter); 186 compile_grep_patterns(&rev.grep_filter);
175 prepare_revision_walk(&rev); 187 prepare_revision_walk(&rev);
176 188
177 if (pager) 189 if (pager)
178 html("<table class='list nowrap'>"); 190 html("<table class='list nowrap'>");
179 191
180 html("<tr class='nohover'><th class='left'>Age</th>" 192 html("<tr class='nohover'><th class='left'>Age</th>"
181 "<th class='left'>Commit message"); 193 "<th class='left'>Commit message");
182 if (pager) { 194 if (pager) {
183 html(" ("); 195 html(" (");
184 cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, 196 cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL,
185 NULL, ctx.qry.head, ctx.qry.sha1, 197 NULL, ctx.qry.head, ctx.qry.sha1,
186 ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep, 198 ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep,
187 ctx.qry.search, ctx.qry.showmsg ? 0 : 1); 199 ctx.qry.search, ctx.qry.showmsg ? 0 : 1);
188 html(")"); 200 html(")");
189 } 201 }
190 html("</th><th class='left'>Author</th>"); 202 html("</th><th class='left'>Author</th>");
191 if (ctx.repo->enable_log_filecount) { 203 if (ctx.repo->enable_log_filecount) {
192 html("<th class='left'>Files</th>"); 204 html("<th class='left'>Files</th>");
193 columns++; 205 columns++;
194 if (ctx.repo->enable_log_linecount) { 206 if (ctx.repo->enable_log_linecount) {
195 html("<th class='left'>Lines</th>"); 207 html("<th class='left'>Lines</th>");
196 columns++; 208 columns++;
197 } 209 }
198 } 210 }
199 html("</tr>\n"); 211 html("</tr>\n");
200 212
201 if (ofs<0) 213 if (ofs<0)
202 ofs = 0; 214 ofs = 0;
203 215
204 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { 216 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) {
205 free(commit->buffer); 217 free(commit->buffer);
206 commit->buffer = NULL; 218 commit->buffer = NULL;
207 free_commit_list(commit->parents); 219 free_commit_list(commit->parents);
208 commit->parents = NULL; 220 commit->parents = NULL;
209 } 221 }
210 222
211 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { 223 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) {
212 print_commit(commit); 224 print_commit(commit);
213 free(commit->buffer); 225 free(commit->buffer);
214 commit->buffer = NULL; 226 commit->buffer = NULL;
215 free_commit_list(commit->parents); 227 free_commit_list(commit->parents);
216 commit->parents = NULL; 228 commit->parents = NULL;
217 } 229 }
218 if (pager) { 230 if (pager) {