summaryrefslogtreecommitdiffabout
authorJeff Smith <whydoubt@yahoo.com>2010-07-29 14:32:31 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-08-04 01:10:07 (UTC)
commit39c2e224d3c55dfa1a7668399897be295be07dc7 (patch) (unidiff)
tree361f85c61886eecf153243fae1ada8a7618d8728
parent059b39344fdcde324dff1099fc4b70c7aab12a96 (diff)
downloadcgit-39c2e224d3c55dfa1a7668399897be295be07dc7.zip
cgit-39c2e224d3c55dfa1a7668399897be295be07dc7.tar.gz
cgit-39c2e224d3c55dfa1a7668399897be295be07dc7.tar.bz2
ui-log: Display git notes when present
Signed-off-by: Jeff Smith <whydoubt@yahoo.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.css11
-rw-r--r--ui-log.c12
2 files changed, 23 insertions, 0 deletions
diff --git a/cgit.css b/cgit.css
index 3675697..0c88b65 100644
--- a/cgit.css
+++ b/cgit.css
@@ -119,96 +119,107 @@ div.content {
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}
diff --git a/ui-log.c b/ui-log.c
index ee93653..7f38d2a 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -66,105 +66,117 @@ void show_commit_decorations(struct commit *commit)
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);