summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.css24
-rw-r--r--ui-log.c35
2 files changed, 59 insertions, 0 deletions
diff --git a/cgit.css b/cgit.css
index 7928c2f..f19446d 100644
--- a/cgit.css
+++ b/cgit.css
@@ -1,473 +1,497 @@
1body, table, form { 1body, table, form {
2 padding: 0em; 2 padding: 0em;
3 margin: 0em; 3 margin: 0em;
4} 4}
5 5
6body { 6body {
7 font-family: sans-serif; 7 font-family: sans-serif;
8 font-size: 10pt; 8 font-size: 10pt;
9 color: #333; 9 color: #333;
10 background: white; 10 background: white;
11 padding: 4px; 11 padding: 4px;
12} 12}
13 13
14a { 14a {
15 color: blue; 15 color: blue;
16 text-decoration: none; 16 text-decoration: none;
17} 17}
18 18
19a:hover { 19a:hover {
20 text-decoration: underline; 20 text-decoration: underline;
21} 21}
22 22
23table { 23table {
24 border-collapse: collapse; 24 border-collapse: collapse;
25} 25}
26 26
27table#header { 27table#header {
28 width: 100%; 28 width: 100%;
29 margin-bottom: 1em; 29 margin-bottom: 1em;
30} 30}
31 31
32table#header td.logo { 32table#header td.logo {
33 width: 96px; 33 width: 96px;
34} 34}
35 35
36table#header td.main { 36table#header td.main {
37 font-size: 250%; 37 font-size: 250%;
38 padding-left: 10px; 38 padding-left: 10px;
39 white-space: nowrap; 39 white-space: nowrap;
40} 40}
41 41
42table#header td.main a { 42table#header td.main a {
43 color: #000; 43 color: #000;
44} 44}
45 45
46table#header td.form { 46table#header td.form {
47 text-align: right; 47 text-align: right;
48 vertical-align: bottom; 48 vertical-align: bottom;
49 padding-right: 1em; 49 padding-right: 1em;
50 padding-bottom: 2px; 50 padding-bottom: 2px;
51 white-space: nowrap; 51 white-space: nowrap;
52} 52}
53 53
54table#header td.form form, 54table#header td.form form,
55table#header td.form input, 55table#header td.form input,
56table#header td.form select { 56table#header td.form select {
57 font-size: 90%; 57 font-size: 90%;
58} 58}
59 59
60table#header td.sub { 60table#header td.sub {
61 color: #777; 61 color: #777;
62 border-top: solid 1px #ccc; 62 border-top: solid 1px #ccc;
63 padding-left: 10px; 63 padding-left: 10px;
64} 64}
65 65
66table.tabs { 66table.tabs {
67 /* border-bottom: solid 2px #ccc; */ 67 /* border-bottom: solid 2px #ccc; */
68 border-collapse: collapse; 68 border-collapse: collapse;
69 margin-top: 2em; 69 margin-top: 2em;
70 margin-bottom: 0px; 70 margin-bottom: 0px;
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.content { 105div.content {
106 margin: 0px; 106 margin: 0px;
107 padding: 2em; 107 padding: 2em;
108 border-top: solid 3px #ccc; 108 border-top: solid 3px #ccc;
109 border-bottom: solid 3px #ccc; 109 border-bottom: solid 3px #ccc;
110} 110}
111 111
112 112
113table.list { 113table.list {
114 width: 100%; 114 width: 100%;
115 border: none; 115 border: none;
116 border-collapse: collapse; 116 border-collapse: collapse;
117} 117}
118 118
119table.list tr { 119table.list tr {
120 background: white; 120 background: white;
121} 121}
122 122
123table.list tr.logheader { 123table.list tr.logheader {
124 background: #eee; 124 background: #eee;
125} 125}
126 126
127table.list tr:hover { 127table.list tr:hover {
128 background: #eee; 128 background: #eee;
129} 129}
130 130
131table.list tr.nohover:hover { 131table.list tr.nohover:hover {
132 background: white; 132 background: white;
133} 133}
134 134
135table.list th { 135table.list th {
136 font-weight: bold; 136 font-weight: bold;
137 /* color: #888; 137 /* color: #888;
138 border-top: dashed 1px #888; 138 border-top: dashed 1px #888;
139 border-bottom: dashed 1px #888; 139 border-bottom: dashed 1px #888;
140 */ 140 */
141 padding: 0.1em 0.5em 0.05em 0.5em; 141 padding: 0.1em 0.5em 0.05em 0.5em;
142 vertical-align: baseline; 142 vertical-align: baseline;
143} 143}
144 144
145table.list td { 145table.list td {
146 border: none; 146 border: none;
147 padding: 0.1em 0.5em 0.1em 0.5em; 147 padding: 0.1em 0.5em 0.1em 0.5em;
148} 148}
149 149
150table.list td.logsubject { 150table.list td.logsubject {
151 font-family: monospace; 151 font-family: monospace;
152 font-weight: bold; 152 font-weight: bold;
153} 153}
154 154
155table.list td.logmsg { 155table.list td.logmsg {
156 font-family: monospace; 156 font-family: monospace;
157 white-space: pre; 157 white-space: pre;
158 padding: 1em 0em 2em 0em; 158 padding: 1em 0em 2em 0em;
159} 159}
160 160
161table.list td a { 161table.list td a {
162 color: black; 162 color: black;
163} 163}
164 164
165table.list td a:hover { 165table.list td a:hover {
166 color: #00f; 166 color: #00f;
167} 167}
168 168
169img { 169img {
170 border: none; 170 border: none;
171} 171}
172 172
173input#switch-btn { 173input#switch-btn {
174 margin: 2px 0px 0px 0px; 174 margin: 2px 0px 0px 0px;
175} 175}
176 176
177td#sidebar input.txt { 177td#sidebar input.txt {
178 width: 100%; 178 width: 100%;
179 margin: 2px 0px 0px 0px; 179 margin: 2px 0px 0px 0px;
180} 180}
181 181
182table#grid { 182table#grid {
183 margin: 0px; 183 margin: 0px;
184} 184}
185 185
186td#content { 186td#content {
187 vertical-align: top; 187 vertical-align: top;
188 padding: 1em 2em 1em 1em; 188 padding: 1em 2em 1em 1em;
189 border: none; 189 border: none;
190} 190}
191 191
192div#summary { 192div#summary {
193 vertical-align: top; 193 vertical-align: top;
194 margin-bottom: 1em; 194 margin-bottom: 1em;
195} 195}
196 196
197table#downloads { 197table#downloads {
198 float: right; 198 float: right;
199 border-collapse: collapse; 199 border-collapse: collapse;
200 border: solid 1px #777; 200 border: solid 1px #777;
201 margin-left: 0.5em; 201 margin-left: 0.5em;
202 margin-bottom: 0.5em; 202 margin-bottom: 0.5em;
203} 203}
204 204
205table#downloads th { 205table#downloads th {
206 background-color: #ccc; 206 background-color: #ccc;
207} 207}
208 208
209div#blob { 209div#blob {
210 border: solid 1px black; 210 border: solid 1px black;
211} 211}
212 212
213div.error { 213div.error {
214 color: red; 214 color: red;
215 font-weight: bold; 215 font-weight: bold;
216 margin: 1em 2em; 216 margin: 1em 2em;
217} 217}
218 218
219a.ls-blob, a.ls-dir, a.ls-mod { 219a.ls-blob, a.ls-dir, a.ls-mod {
220 font-family: monospace; 220 font-family: monospace;
221} 221}
222 222
223td.ls-size { 223td.ls-size {
224 text-align: right; 224 text-align: right;
225 font-family: monospace; 225 font-family: monospace;
226 width: 10em; 226 width: 10em;
227} 227}
228 228
229td.ls-mode { 229td.ls-mode {
230 font-family: monospace; 230 font-family: monospace;
231 width: 10em; 231 width: 10em;
232} 232}
233 233
234table.blob { 234table.blob {
235 margin-top: 0.5em; 235 margin-top: 0.5em;
236 border-top: solid 1px black; 236 border-top: solid 1px black;
237} 237}
238 238
239table.blob td.no { 239table.blob td.no {
240 border-right: solid 1px black; 240 border-right: solid 1px black;
241 color: black; 241 color: black;
242 background-color: #eee; 242 background-color: #eee;
243 text-align: right; 243 text-align: right;
244} 244}
245 245
246table.blob td.no a { 246table.blob td.no a {
247 color: black; 247 color: black;
248} 248}
249 249
250table.blob td.no a:hover { 250table.blob td.no a:hover {
251 color: black; 251 color: black;
252 text-decoration: none; 252 text-decoration: none;
253} 253}
254 254
255table.blob td.txt { 255table.blob td.txt {
256 white-space: pre; 256 white-space: pre;
257 font-family: monospace; 257 font-family: monospace;
258 padding-left: 0.5em; 258 padding-left: 0.5em;
259} 259}
260 260
261table.nowrap td { 261table.nowrap td {
262 white-space: nowrap; 262 white-space: nowrap;
263} 263}
264 264
265table.commit-info { 265table.commit-info {
266 border-collapse: collapse; 266 border-collapse: collapse;
267 margin-top: 1.5em; 267 margin-top: 1.5em;
268} 268}
269 269
270table.commit-info th { 270table.commit-info th {
271 text-align: left; 271 text-align: left;
272 font-weight: normal; 272 font-weight: normal;
273 padding: 0.1em 1em 0.1em 0.1em; 273 padding: 0.1em 1em 0.1em 0.1em;
274 vertical-align: top; 274 vertical-align: top;
275} 275}
276 276
277table.commit-info td { 277table.commit-info td {
278 font-weight: normal; 278 font-weight: normal;
279 padding: 0.1em 1em 0.1em 0.1em; 279 padding: 0.1em 1em 0.1em 0.1em;
280} 280}
281 281
282div.commit-subject { 282div.commit-subject {
283 font-weight: bold; 283 font-weight: bold;
284 font-size: 125%; 284 font-size: 125%;
285 margin: 1.5em 0em 0.5em 0em; 285 margin: 1.5em 0em 0.5em 0em;
286 padding: 0em; 286 padding: 0em;
287} 287}
288 288
289div.commit-msg { 289div.commit-msg {
290 white-space: pre; 290 white-space: pre;
291 font-family: monospace; 291 font-family: monospace;
292} 292}
293 293
294div.diffstat-header { 294div.diffstat-header {
295 font-weight: bold; 295 font-weight: bold;
296 padding-top: 1.5em; 296 padding-top: 1.5em;
297} 297}
298 298
299table.diffstat { 299table.diffstat {
300 border-collapse: collapse; 300 border-collapse: collapse;
301 border: solid 1px #aaa; 301 border: solid 1px #aaa;
302 background-color: #eee; 302 background-color: #eee;
303} 303}
304 304
305table.diffstat th { 305table.diffstat th {
306 font-weight: normal; 306 font-weight: normal;
307 text-align: left; 307 text-align: left;
308 text-decoration: underline; 308 text-decoration: underline;
309 padding: 0.1em 1em 0.1em 0.1em; 309 padding: 0.1em 1em 0.1em 0.1em;
310 font-size: 100%; 310 font-size: 100%;
311} 311}
312 312
313table.diffstat td { 313table.diffstat td {
314 padding: 0.2em 0.2em 0.1em 0.1em; 314 padding: 0.2em 0.2em 0.1em 0.1em;
315 font-size: 100%; 315 font-size: 100%;
316 border: none; 316 border: none;
317} 317}
318 318
319table.diffstat td.mode { 319table.diffstat td.mode {
320 white-space: nowrap; 320 white-space: nowrap;
321} 321}
322 322
323table.diffstat td span.modechange { 323table.diffstat td span.modechange {
324 padding-left: 1em; 324 padding-left: 1em;
325 color: red; 325 color: red;
326} 326}
327 327
328table.diffstat td.add a { 328table.diffstat td.add a {
329 color: green; 329 color: green;
330} 330}
331 331
332table.diffstat td.del a { 332table.diffstat td.del a {
333 color: red; 333 color: red;
334} 334}
335 335
336table.diffstat td.upd a { 336table.diffstat td.upd a {
337 color: blue; 337 color: blue;
338} 338}
339 339
340table.diffstat td.graph { 340table.diffstat td.graph {
341 width: 500px; 341 width: 500px;
342 vertical-align: middle; 342 vertical-align: middle;
343} 343}
344 344
345table.diffstat td.graph table { 345table.diffstat td.graph table {
346 border: none; 346 border: none;
347} 347}
348 348
349table.diffstat td.graph td { 349table.diffstat td.graph td {
350 padding: 0px; 350 padding: 0px;
351 border: 0px; 351 border: 0px;
352 height: 7pt; 352 height: 7pt;
353} 353}
354 354
355table.diffstat td.graph td.add { 355table.diffstat td.graph td.add {
356 background-color: #5c5; 356 background-color: #5c5;
357} 357}
358 358
359table.diffstat td.graph td.rem { 359table.diffstat td.graph td.rem {
360 background-color: #c55; 360 background-color: #c55;
361} 361}
362 362
363div.diffstat-summary { 363div.diffstat-summary {
364 color: #888; 364 color: #888;
365 padding-top: 0.5em; 365 padding-top: 0.5em;
366} 366}
367 367
368table.diff { 368table.diff {
369 width: 100%; 369 width: 100%;
370} 370}
371 371
372table.diff td { 372table.diff td {
373 font-family: monospace; 373 font-family: monospace;
374 white-space: pre; 374 white-space: pre;
375} 375}
376 376
377table.diff td div.head { 377table.diff td div.head {
378 font-weight: bold; 378 font-weight: bold;
379 margin-top: 1em; 379 margin-top: 1em;
380 color: black; 380 color: black;
381} 381}
382 382
383table.diff td div.hunk { 383table.diff td div.hunk {
384 color: #009; 384 color: #009;
385} 385}
386 386
387table.diff td div.add { 387table.diff td div.add {
388 color: green; 388 color: green;
389} 389}
390 390
391table.diff td div.del { 391table.diff td div.del {
392 color: red; 392 color: red;
393} 393}
394 394
395.sha1 { 395.sha1 {
396 font-family: monospace; 396 font-family: monospace;
397 font-size: 90%; 397 font-size: 90%;
398} 398}
399 399
400.left { 400.left {
401 text-align: left; 401 text-align: left;
402} 402}
403 403
404.right { 404.right {
405 text-align: right; 405 text-align: right;
406} 406}
407 407
408table.list td.repogroup { 408table.list td.repogroup {
409 font-style: italic; 409 font-style: italic;
410 color: #888; 410 color: #888;
411} 411}
412 412
413a.button { 413a.button {
414 font-size: 80%; 414 font-size: 80%;
415 padding: 0em 0.5em; 415 padding: 0em 0.5em;
416} 416}
417 417
418a.primary { 418a.primary {
419 font-size: 100%; 419 font-size: 100%;
420} 420}
421 421
422a.secondary { 422a.secondary {
423 font-size: 90%; 423 font-size: 90%;
424} 424}
425 425
426td.toplevel-repo { 426td.toplevel-repo {
427 427
428} 428}
429 429
430table.list td.sublevel-repo { 430table.list td.sublevel-repo {
431 padding-left: 1.5em; 431 padding-left: 1.5em;
432} 432}
433 433
434div.pager { 434div.pager {
435 text-align: center; 435 text-align: center;
436 margin: 1em 0em 0em 0em; 436 margin: 1em 0em 0em 0em;
437} 437}
438 438
439div.pager a { 439div.pager a {
440 color: #777; 440 color: #777;
441 margin: 0em 0.5em; 441 margin: 0em 0.5em;
442} 442}
443 443
444span.age-mins { 444span.age-mins {
445 font-weight: bold; 445 font-weight: bold;
446 color: #080; 446 color: #080;
447} 447}
448 448
449span.age-hours { 449span.age-hours {
450 color: #080; 450 color: #080;
451} 451}
452 452
453span.age-days { 453span.age-days {
454 color: #040; 454 color: #040;
455} 455}
456 456
457span.age-weeks { 457span.age-weeks {
458 color: #444; 458 color: #444;
459} 459}
460 460
461span.age-months { 461span.age-months {
462 color: #888; 462 color: #888;
463} 463}
464 464
465span.age-years { 465span.age-years {
466 color: #bbb; 466 color: #bbb;
467} 467}
468div.footer { 468div.footer {
469 margin-top: 0.5em; 469 margin-top: 0.5em;
470 text-align: center; 470 text-align: center;
471 font-size: 80%; 471 font-size: 80%;
472 color: #ccc; 472 color: #ccc;
473} 473}
474a.branch-deco {
475 margin: 0px 0.5em;
476 padding: 0px 0.25em;
477 background-color: #88ff88;
478 border: solid 1px #007700;
479}
480a.tag-deco {
481 margin: 0px 0.5em;
482 padding: 0px 0.25em;
483 background-color: #ffff88;
484 border: solid 1px #777700;
485}
486a.remote-deco {
487 margin: 0px 0.5em;
488 padding: 0px 0.25em;
489 background-color: #ccccff;
490 border: solid 1px #000077;
491}
492a.deco {
493 margin: 0px 0.5em;
494 padding: 0px 0.25em;
495 background-color: #ff8888;
496 border: solid 1px #770000;
497}
diff --git a/ui-log.c b/ui-log.c
index 2f90778..c3757dd 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -1,189 +1,224 @@
1/* ui-log.c: functions for log output 1/* ui-log.c: functions for log output
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 12
13int files, add_lines, rem_lines; 13int files, add_lines, rem_lines;
14 14
15void count_lines(char *line, int size) 15void count_lines(char *line, int size)
16{ 16{
17 if (size <= 0) 17 if (size <= 0)
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 files++; 29 files++;
30 if (ctx.repo->enable_log_linecount) 30 if (ctx.repo->enable_log_linecount)
31 cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); 31 cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines);
32} 32}
33 33
34void show_commit_decorations(struct commit *commit)
35{
36 struct name_decoration *deco;
37 static char buf[1024];
38
39 buf[sizeof(buf) - 1] = 0;
40 deco = lookup_decoration(&name_decoration, &commit->object);
41 while (deco) {
42 if (!prefixcmp(deco->name, "refs/heads/")) {
43 strncpy(buf, deco->name + 11, sizeof(buf) - 1);
44 cgit_log_link(buf, NULL, "branch-deco", buf, NULL, NULL,
45 0, NULL, NULL, ctx.qry.showmsg);
46 }
47 else if (!prefixcmp(deco->name, "tag: refs/tags/")) {
48 strncpy(buf, deco->name + 15, sizeof(buf) - 1);
49 cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);
50 }
51 else if (!prefixcmp(deco->name, "refs/remotes/")) {
52 strncpy(buf, deco->name + 13, sizeof(buf) - 1);
53 cgit_log_link(buf, NULL, "remote-deco", NULL,
54 sha1_to_hex(commit->object.sha1), NULL,
55 0, NULL, NULL, ctx.qry.showmsg);
56 }
57 else {
58 strncpy(buf, deco->name, sizeof(buf) - 1);
59 cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
60 sha1_to_hex(commit->object.sha1));
61 }
62 deco = deco->next;
63 }
64}
65
34void print_commit(struct commit *commit) 66void print_commit(struct commit *commit)
35{ 67{
36 struct commitinfo *info; 68 struct commitinfo *info;
37 char *tmp; 69 char *tmp;
38 int cols = 2; 70 int cols = 2;
39 71
40 info = cgit_parse_commit(commit); 72 info = cgit_parse_commit(commit);
41 htmlf("<tr%s><td>", 73 htmlf("<tr%s><td>",
42 ctx.qry.showmsg ? " class='logheader'" : ""); 74 ctx.qry.showmsg ? " class='logheader'" : "");
43 tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1)); 75 tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1));
44 tmp = cgit_pageurl(ctx.repo->url, "commit", tmp); 76 tmp = cgit_pageurl(ctx.repo->url, "commit", tmp);
45 html_link_open(tmp, NULL, NULL); 77 html_link_open(tmp, NULL, NULL);
46 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); 78 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
47 html_link_close(); 79 html_link_close();
48 htmlf("</td><td%s>", 80 htmlf("</td><td%s>",
49 ctx.qry.showmsg ? " class='logsubject'" : ""); 81 ctx.qry.showmsg ? " class='logsubject'" : "");
50 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, 82 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
51 sha1_to_hex(commit->object.sha1)); 83 sha1_to_hex(commit->object.sha1));
84 show_commit_decorations(commit);
52 html("</td><td>"); 85 html("</td><td>");
53 html_txt(info->author); 86 html_txt(info->author);
54 if (ctx.repo->enable_log_filecount) { 87 if (ctx.repo->enable_log_filecount) {
55 files = 0; 88 files = 0;
56 add_lines = 0; 89 add_lines = 0;
57 rem_lines = 0; 90 rem_lines = 0;
58 cgit_diff_commit(commit, inspect_files); 91 cgit_diff_commit(commit, inspect_files);
59 html("</td><td>"); 92 html("</td><td>");
60 htmlf("%d", files); 93 htmlf("%d", files);
61 if (ctx.repo->enable_log_linecount) { 94 if (ctx.repo->enable_log_linecount) {
62 html("</td><td>"); 95 html("</td><td>");
63 htmlf("-%d/+%d", rem_lines, add_lines); 96 htmlf("-%d/+%d", rem_lines, add_lines);
64 } 97 }
65 } 98 }
66 html("</td></tr>\n"); 99 html("</td></tr>\n");
67 if (ctx.qry.showmsg) { 100 if (ctx.qry.showmsg) {
68 if (ctx.repo->enable_log_filecount) { 101 if (ctx.repo->enable_log_filecount) {
69 cols++; 102 cols++;
70 if (ctx.repo->enable_log_linecount) 103 if (ctx.repo->enable_log_linecount)
71 cols++; 104 cols++;
72 } 105 }
73 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>", 106 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>",
74 cols); 107 cols);
75 html_txt(info->msg); 108 html_txt(info->msg);
76 html("</td></tr>\n"); 109 html("</td></tr>\n");
77 } 110 }
78 cgit_free_commitinfo(info); 111 cgit_free_commitinfo(info);
79} 112}
80 113
81static const char *disambiguate_ref(const char *ref) 114static const char *disambiguate_ref(const char *ref)
82{ 115{
83 unsigned char sha1[20]; 116 unsigned char sha1[20];
84 const char *longref; 117 const char *longref;
85 118
86 longref = fmt("refs/heads/%s", ref); 119 longref = fmt("refs/heads/%s", ref);
87 if (get_sha1(longref, sha1) == 0) 120 if (get_sha1(longref, sha1) == 0)
88 return longref; 121 return longref;
89 122
90 return ref; 123 return ref;
91} 124}
92 125
93void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, 126void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
94 char *path, int pager) 127 char *path, int pager)
95{ 128{
96 struct rev_info rev; 129 struct rev_info rev;
97 struct commit *commit; 130 struct commit *commit;
98 const char *argv[] = {NULL, NULL, NULL, NULL, NULL}; 131 const char *argv[] = {NULL, NULL, NULL, NULL, NULL};
99 int argc = 2; 132 int argc = 2;
100 int i, columns = 3; 133 int i, columns = 3;
101 134
102 if (!tip) 135 if (!tip)
103 tip = ctx.qry.head; 136 tip = ctx.qry.head;
104 137
105 argv[1] = disambiguate_ref(tip); 138 argv[1] = disambiguate_ref(tip);
106 139
107 if (grep && pattern && (!strcmp(grep, "grep") || 140 if (grep && pattern && (!strcmp(grep, "grep") ||
108 !strcmp(grep, "author") || 141 !strcmp(grep, "author") ||
109 !strcmp(grep, "committer"))) 142 !strcmp(grep, "committer")))
110 argv[argc++] = fmt("--%s=%s", grep, pattern); 143 argv[argc++] = fmt("--%s=%s", grep, pattern);
111 144
112 if (path) { 145 if (path) {
113 argv[argc++] = "--"; 146 argv[argc++] = "--";
114 argv[argc++] = path; 147 argv[argc++] = path;
115 } 148 }
116 init_revisions(&rev, NULL); 149 init_revisions(&rev, NULL);
117 rev.abbrev = DEFAULT_ABBREV; 150 rev.abbrev = DEFAULT_ABBREV;
118 rev.commit_format = CMIT_FMT_DEFAULT; 151 rev.commit_format = CMIT_FMT_DEFAULT;
119 rev.verbose_header = 1; 152 rev.verbose_header = 1;
120 rev.show_root_diff = 0; 153 rev.show_root_diff = 0;
121 setup_revisions(argc, argv, &rev, NULL); 154 setup_revisions(argc, argv, &rev, NULL);
155 load_ref_decorations();
156 rev.show_decorations = 1;
122 rev.grep_filter.regflags |= REG_ICASE; 157 rev.grep_filter.regflags |= REG_ICASE;
123 compile_grep_patterns(&rev.grep_filter); 158 compile_grep_patterns(&rev.grep_filter);
124 prepare_revision_walk(&rev); 159 prepare_revision_walk(&rev);
125 160
126 if (pager) 161 if (pager)
127 html("<table class='list nowrap'>"); 162 html("<table class='list nowrap'>");
128 163
129 html("<tr class='nohover'><th class='left'>Age</th>" 164 html("<tr class='nohover'><th class='left'>Age</th>"
130 "<th class='left'>Commit message"); 165 "<th class='left'>Commit message");
131 if (pager) { 166 if (pager) {
132 html(" ("); 167 html(" (");
133 cgit_log_link("toggle", NULL, NULL, ctx.qry.head, ctx.qry.sha1, 168 cgit_log_link("toggle", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
134 ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, 169 ctx.qry.path, ctx.qry.ofs, ctx.qry.grep,
135 ctx.qry.search, ctx.qry.showmsg ? 0 : 1); 170 ctx.qry.search, ctx.qry.showmsg ? 0 : 1);
136 html(")"); 171 html(")");
137 } 172 }
138 html("</th><th class='left'>Author</th>"); 173 html("</th><th class='left'>Author</th>");
139 if (ctx.repo->enable_log_filecount) { 174 if (ctx.repo->enable_log_filecount) {
140 html("<th class='left'>Files</th>"); 175 html("<th class='left'>Files</th>");
141 columns++; 176 columns++;
142 if (ctx.repo->enable_log_linecount) { 177 if (ctx.repo->enable_log_linecount) {
143 html("<th class='left'>Lines</th>"); 178 html("<th class='left'>Lines</th>");
144 columns++; 179 columns++;
145 } 180 }
146 } 181 }
147 html("</tr>\n"); 182 html("</tr>\n");
148 183
149 if (ofs<0) 184 if (ofs<0)
150 ofs = 0; 185 ofs = 0;
151 186
152 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { 187 for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) {
153 free(commit->buffer); 188 free(commit->buffer);
154 commit->buffer = NULL; 189 commit->buffer = NULL;
155 free_commit_list(commit->parents); 190 free_commit_list(commit->parents);
156 commit->parents = NULL; 191 commit->parents = NULL;
157 } 192 }
158 193
159 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { 194 for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) {
160 print_commit(commit); 195 print_commit(commit);
161 free(commit->buffer); 196 free(commit->buffer);
162 commit->buffer = NULL; 197 commit->buffer = NULL;
163 free_commit_list(commit->parents); 198 free_commit_list(commit->parents);
164 commit->parents = NULL; 199 commit->parents = NULL;
165 } 200 }
166 if (pager) { 201 if (pager) {
167 htmlf("</table><div class='pager'>", 202 htmlf("</table><div class='pager'>",
168 columns); 203 columns);
169 if (ofs > 0) { 204 if (ofs > 0) {
170 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, 205 cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
171 ctx.qry.sha1, ctx.qry.path, 206 ctx.qry.sha1, ctx.qry.path,
172 ofs - cnt, ctx.qry.grep, 207 ofs - cnt, ctx.qry.grep,
173 ctx.qry.search, ctx.qry.showmsg); 208 ctx.qry.search, ctx.qry.showmsg);
174 html("&nbsp;"); 209 html("&nbsp;");
175 } 210 }
176 if ((commit = get_revision(&rev)) != NULL) { 211 if ((commit = get_revision(&rev)) != NULL) {
177 cgit_log_link("[next]", NULL, NULL, ctx.qry.head, 212 cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
178 ctx.qry.sha1, ctx.qry.path, 213 ctx.qry.sha1, ctx.qry.path,
179 ofs + cnt, ctx.qry.grep, 214 ofs + cnt, ctx.qry.grep,
180 ctx.qry.search, ctx.qry.showmsg); 215 ctx.qry.search, ctx.qry.showmsg);
181 } 216 }
182 html("</div>"); 217 html("</div>");
183 } else if ((commit = get_revision(&rev)) != NULL) { 218 } else if ((commit = get_revision(&rev)) != NULL) {
184 html("<tr class='nohover'><td colspan='3'>"); 219 html("<tr class='nohover'><td colspan='3'>");
185 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, 220 cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0,
186 NULL, NULL, ctx.qry.showmsg); 221 NULL, NULL, ctx.qry.showmsg);
187 html("</td></tr>\n"); 222 html("</td></tr>\n");
188 } 223 }
189} 224}