summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2009-01-11 11:16:18 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2009-01-11 11:16:18 (UTC)
commitef2dc552b298e5c65db8fbe5ff1c375e50d0f057 (patch) (unidiff)
treeb3bbb563c58026c4fbf366424be08846bce3096e
parent5164be32778e2bca146e13904e5b9e79d0d6cca8 (diff)
downloadcgit-ef2dc552b298e5c65db8fbe5ff1c375e50d0f057.zip
cgit-ef2dc552b298e5c65db8fbe5ff1c375e50d0f057.tar.gz
cgit-ef2dc552b298e5c65db8fbe5ff1c375e50d0f057.tar.bz2
ui-log: show name-decorations in log output
Commits are now decorated with a clickable 'label' for each ref pointing at it, similar to how gitweb and gitk displays commit decorations. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
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
@@ -462,12 +462,36 @@ span.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
@@ -22,42 +22,75 @@ void count_lines(char *line, int size)
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);
@@ -110,24 +143,26 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
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,