author | Lars Hjemli <hjemli@gmail.com> | 2007-05-15 23:16:56 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-15 23:16:56 (UTC) |
commit | dff894d12953a8a3cd7cdca2357771212a2f57d6 (patch) (unidiff) | |
tree | 042f1fbc0594d61d97721167197506760847ce2a | |
parent | f9ff7df613b4ee86fe5914c4ae3400650882c03d (diff) | |
download | cgit-dff894d12953a8a3cd7cdca2357771212a2f57d6.zip cgit-dff894d12953a8a3cd7cdca2357771212a2f57d6.tar.gz cgit-dff894d12953a8a3cd7cdca2357771212a2f57d6.tar.bz2 |
Add link to commitdiff below diffstat
This link is a lot easier to locate than the links to the right of the
parent entries.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.css | 6 | ||||
-rw-r--r-- | ui-commit.c | 6 |
2 files changed, 10 insertions, 2 deletions
@@ -143,195 +143,199 @@ td#search input { | |||
143 | td#summary { | 143 | td#summary { |
144 | vertical-align: top; | 144 | vertical-align: top; |
145 | padding-bottom: 1em; | 145 | padding-bottom: 1em; |
146 | } | 146 | } |
147 | 147 | ||
148 | td#archivelist { | 148 | td#archivelist { |
149 | padding-bottom: 1em; | 149 | padding-bottom: 1em; |
150 | } | 150 | } |
151 | 151 | ||
152 | td#archivelist table { | 152 | td#archivelist table { |
153 | float: right; | 153 | float: right; |
154 | border-collapse: collapse; | 154 | border-collapse: collapse; |
155 | border: solid 1px #777; | 155 | border: solid 1px #777; |
156 | } | 156 | } |
157 | 157 | ||
158 | td#archivelist table th { | 158 | td#archivelist table th { |
159 | background-color: #ccc; | 159 | background-color: #ccc; |
160 | } | 160 | } |
161 | 161 | ||
162 | td#content { | 162 | td#content { |
163 | padding: 1em 0.5em; | 163 | padding: 1em 0.5em; |
164 | } | 164 | } |
165 | 165 | ||
166 | div#blob { | 166 | div#blob { |
167 | border: solid 1px black; | 167 | border: solid 1px black; |
168 | } | 168 | } |
169 | 169 | ||
170 | div.error { | 170 | div.error { |
171 | color: red; | 171 | color: red; |
172 | font-weight: bold; | 172 | font-weight: bold; |
173 | margin: 1em 2em; | 173 | margin: 1em 2em; |
174 | } | 174 | } |
175 | 175 | ||
176 | td.ls-blob, td.ls-dir, td.ls-mod { | 176 | td.ls-blob, td.ls-dir, td.ls-mod { |
177 | font-family: monospace; | 177 | font-family: monospace; |
178 | } | 178 | } |
179 | 179 | ||
180 | div.ls-dir a { | 180 | div.ls-dir a { |
181 | font-weight: bold; | 181 | font-weight: bold; |
182 | } | 182 | } |
183 | 183 | ||
184 | th.filesize, td.filesize { | 184 | th.filesize, td.filesize { |
185 | text-align: right; | 185 | text-align: right; |
186 | } | 186 | } |
187 | 187 | ||
188 | td.filesize { | 188 | td.filesize { |
189 | font-family: monospace; | 189 | font-family: monospace; |
190 | } | 190 | } |
191 | 191 | ||
192 | td.links { | 192 | td.links { |
193 | font-size: 80%; | 193 | font-size: 80%; |
194 | padding-left: 2em; | 194 | padding-left: 2em; |
195 | } | 195 | } |
196 | 196 | ||
197 | td.filemode { | 197 | td.filemode { |
198 | font-family: monospace; | 198 | font-family: monospace; |
199 | } | 199 | } |
200 | 200 | ||
201 | td.blob { | 201 | td.blob { |
202 | white-space: pre; | 202 | white-space: pre; |
203 | font-family: monospace; | 203 | font-family: monospace; |
204 | background-color: white; | 204 | background-color: white; |
205 | } | 205 | } |
206 | 206 | ||
207 | table.nowrap td { | 207 | table.nowrap td { |
208 | white-space: nowrap; | 208 | white-space: nowrap; |
209 | } | 209 | } |
210 | 210 | ||
211 | table.commit-info { | 211 | table.commit-info { |
212 | border-collapse: collapse; | 212 | border-collapse: collapse; |
213 | margin-top: 1.5em; | 213 | margin-top: 1.5em; |
214 | } | 214 | } |
215 | 215 | ||
216 | table.commit-info th { | 216 | table.commit-info th { |
217 | text-align: left; | 217 | text-align: left; |
218 | font-weight: normal; | 218 | font-weight: normal; |
219 | padding: 0.1em 1em 0.1em 0.1em; | 219 | padding: 0.1em 1em 0.1em 0.1em; |
220 | } | 220 | } |
221 | 221 | ||
222 | table.commit-info td { | 222 | table.commit-info td { |
223 | font-weight: normal; | 223 | font-weight: normal; |
224 | padding: 0.1em 1em 0.1em 0.1em; | 224 | padding: 0.1em 1em 0.1em 0.1em; |
225 | } | 225 | } |
226 | 226 | ||
227 | div.commit-subject { | 227 | div.commit-subject { |
228 | font-weight: bold; | 228 | font-weight: bold; |
229 | font-size: 125%; | 229 | font-size: 125%; |
230 | margin: 1.5em 0em 0.5em 0em; | 230 | margin: 1.5em 0em 0.5em 0em; |
231 | padding: 0em; | 231 | padding: 0em; |
232 | } | 232 | } |
233 | 233 | ||
234 | div.commit-msg { | 234 | div.commit-msg { |
235 | white-space: pre; | 235 | white-space: pre; |
236 | font-family: monospace; | 236 | font-family: monospace; |
237 | } | 237 | } |
238 | 238 | ||
239 | div.diffstat-header { | ||
240 | font-weight: bold; | ||
241 | padding-top: 1.5em; | ||
242 | } | ||
243 | |||
239 | table.diffstat { | 244 | table.diffstat { |
240 | border-collapse: collapse; | 245 | border-collapse: collapse; |
241 | margin-top: 1.5em; | ||
242 | width: 100%; | 246 | width: 100%; |
243 | border: solid 1px #aaa; | 247 | border: solid 1px #aaa; |
244 | background-color: #eee; | 248 | background-color: #eee; |
245 | } | 249 | } |
246 | 250 | ||
247 | table.diffstat tr:hover { | 251 | table.diffstat tr:hover { |
248 | background-color: #ccc; | 252 | background-color: #ccc; |
249 | } | 253 | } |
250 | 254 | ||
251 | table.diffstat th { | 255 | table.diffstat th { |
252 | font-weight: normal; | 256 | font-weight: normal; |
253 | text-align: left; | 257 | text-align: left; |
254 | text-decoration: underline; | 258 | text-decoration: underline; |
255 | padding: 0.1em 1em 0.1em 0.1em; | 259 | padding: 0.1em 1em 0.1em 0.1em; |
256 | font-size: 100%; | 260 | font-size: 100%; |
257 | } | 261 | } |
258 | 262 | ||
259 | table.diffstat td { | 263 | table.diffstat td { |
260 | padding: 0.2em 0.2em 0.1em 0.1em; | 264 | padding: 0.2em 0.2em 0.1em 0.1em; |
261 | font-size: 100%; | 265 | font-size: 100%; |
262 | border: none; | 266 | border: none; |
263 | } | 267 | } |
264 | 268 | ||
265 | table.diffstat td span.modechange { | 269 | table.diffstat td span.modechange { |
266 | padding-left: 1em; | 270 | padding-left: 1em; |
267 | color: red; | 271 | color: red; |
268 | } | 272 | } |
269 | 273 | ||
270 | table.diffstat td.add a { | 274 | table.diffstat td.add a { |
271 | color: green; | 275 | color: green; |
272 | } | 276 | } |
273 | 277 | ||
274 | table.diffstat td.del a { | 278 | table.diffstat td.del a { |
275 | color: red; | 279 | color: red; |
276 | } | 280 | } |
277 | 281 | ||
278 | table.diffstat td.upd a { | 282 | table.diffstat td.upd a { |
279 | color: blue; | 283 | color: blue; |
280 | } | 284 | } |
281 | 285 | ||
282 | table.diffstat td.graph { | 286 | table.diffstat td.graph { |
283 | width: 75%; | 287 | width: 75%; |
284 | vertical-align: center; | 288 | vertical-align: center; |
285 | } | 289 | } |
286 | 290 | ||
287 | table.diffstat td.graph table { | 291 | table.diffstat td.graph table { |
288 | border: none; | 292 | border: none; |
289 | } | 293 | } |
290 | 294 | ||
291 | table.diffstat td.graph td { | 295 | table.diffstat td.graph td { |
292 | padding: 0px; | 296 | padding: 0px; |
293 | border: 0px; | 297 | border: 0px; |
294 | height: 7pt; | 298 | height: 7pt; |
295 | } | 299 | } |
296 | 300 | ||
297 | table.diffstat td.graph td.add { | 301 | table.diffstat td.graph td.add { |
298 | background-color: #5c5; | 302 | background-color: #5c5; |
299 | } | 303 | } |
300 | 304 | ||
301 | table.diffstat td.graph td.rem { | 305 | table.diffstat td.graph td.rem { |
302 | background-color: #c55; | 306 | background-color: #c55; |
303 | } | 307 | } |
304 | 308 | ||
305 | table.diffstat td.graph td.none { | 309 | table.diffstat td.graph td.none { |
306 | background-color: none; | 310 | background-color: none; |
307 | } | 311 | } |
308 | 312 | ||
309 | div.diffstat-summary { | 313 | div.diffstat-summary { |
310 | color: #888; | 314 | color: #888; |
311 | padding-top: 0.5em; | 315 | padding-top: 0.5em; |
312 | } | 316 | } |
313 | 317 | ||
314 | table.diff td { | 318 | table.diff td { |
315 | font-family: monospace; | 319 | font-family: monospace; |
316 | white-space: pre; | 320 | white-space: pre; |
317 | } | 321 | } |
318 | 322 | ||
319 | table.diff td div.head { | 323 | table.diff td div.head { |
320 | font-weight: bold; | 324 | font-weight: bold; |
321 | padding-top: 1em; | 325 | padding-top: 1em; |
322 | } | 326 | } |
323 | 327 | ||
324 | table.diff td div.hunk { | 328 | table.diff td div.hunk { |
325 | color: #009; | 329 | color: #009; |
326 | } | 330 | } |
327 | 331 | ||
328 | table.diff td div.add { | 332 | table.diff td div.add { |
329 | color: green; | 333 | color: green; |
330 | } | 334 | } |
331 | 335 | ||
332 | table.diff td div.del { | 336 | table.diff td div.del { |
333 | color: red; | 337 | color: red; |
334 | } | 338 | } |
335 | 339 | ||
336 | .sha1 { | 340 | .sha1 { |
337 | font-family: courier; | 341 | font-family: courier; |
diff --git a/ui-commit.c b/ui-commit.c index 93eb8fd..ff1fad3 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -128,109 +128,113 @@ void inspect_filepair(struct diff_filepair *pair) | |||
128 | else | 128 | else |
129 | slots = slots * 2; | 129 | slots = slots * 2; |
130 | items = xrealloc(items, slots * sizeof(struct fileinfo)); | 130 | items = xrealloc(items, slots * sizeof(struct fileinfo)); |
131 | } | 131 | } |
132 | items[files-1].status = pair->status; | 132 | items[files-1].status = pair->status; |
133 | hashcpy(items[files-1].old_sha1, pair->one->sha1); | 133 | hashcpy(items[files-1].old_sha1, pair->one->sha1); |
134 | hashcpy(items[files-1].new_sha1, pair->two->sha1); | 134 | hashcpy(items[files-1].new_sha1, pair->two->sha1); |
135 | items[files-1].old_mode = pair->one->mode; | 135 | items[files-1].old_mode = pair->one->mode; |
136 | items[files-1].new_mode = pair->two->mode; | 136 | items[files-1].new_mode = pair->two->mode; |
137 | items[files-1].old_path = xstrdup(pair->one->path); | 137 | items[files-1].old_path = xstrdup(pair->one->path); |
138 | items[files-1].new_path = xstrdup(pair->two->path); | 138 | items[files-1].new_path = xstrdup(pair->two->path); |
139 | items[files-1].added = lines_added; | 139 | items[files-1].added = lines_added; |
140 | items[files-1].removed = lines_removed; | 140 | items[files-1].removed = lines_removed; |
141 | if (lines_added + lines_removed > max_changes) | 141 | if (lines_added + lines_removed > max_changes) |
142 | max_changes = lines_added + lines_removed; | 142 | max_changes = lines_added + lines_removed; |
143 | total_adds += lines_added; | 143 | total_adds += lines_added; |
144 | total_rems += lines_removed; | 144 | total_rems += lines_removed; |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | void cgit_print_commit(const char *hex) | 148 | void cgit_print_commit(const char *hex) |
149 | { | 149 | { |
150 | struct commit *commit, *parent; | 150 | struct commit *commit, *parent; |
151 | struct commitinfo *info; | 151 | struct commitinfo *info; |
152 | struct commit_list *p; | 152 | struct commit_list *p; |
153 | unsigned char sha1[20]; | 153 | unsigned char sha1[20]; |
154 | char *query; | 154 | char *query; |
155 | char *filename; | 155 | char *filename; |
156 | int i; | 156 | int i; |
157 | 157 | ||
158 | if (get_sha1(hex, sha1)) { | 158 | if (get_sha1(hex, sha1)) { |
159 | cgit_print_error(fmt("Bad object id: %s", hex)); | 159 | cgit_print_error(fmt("Bad object id: %s", hex)); |
160 | return; | 160 | return; |
161 | } | 161 | } |
162 | commit = lookup_commit_reference(sha1); | 162 | commit = lookup_commit_reference(sha1); |
163 | if (!commit) { | 163 | if (!commit) { |
164 | cgit_print_error(fmt("Bad commit reference: %s", hex)); | 164 | cgit_print_error(fmt("Bad commit reference: %s", hex)); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | info = cgit_parse_commit(commit); | 167 | info = cgit_parse_commit(commit); |
168 | 168 | ||
169 | html("<table class='commit-info'>\n"); | 169 | html("<table class='commit-info'>\n"); |
170 | html("<tr><th>author</th><td>"); | 170 | html("<tr><th>author</th><td>"); |
171 | html_txt(info->author); | 171 | html_txt(info->author); |
172 | html(" "); | 172 | html(" "); |
173 | html_txt(info->author_email); | 173 | html_txt(info->author_email); |
174 | html("</td><td class='right'>"); | 174 | html("</td><td class='right'>"); |
175 | cgit_print_date(info->author_date); | 175 | cgit_print_date(info->author_date); |
176 | html("</td></tr>\n"); | 176 | html("</td></tr>\n"); |
177 | html("<tr><th>committer</th><td>"); | 177 | html("<tr><th>committer</th><td>"); |
178 | html_txt(info->committer); | 178 | html_txt(info->committer); |
179 | html(" "); | 179 | html(" "); |
180 | html_txt(info->committer_email); | 180 | html_txt(info->committer_email); |
181 | html("</td><td class='right'>"); | 181 | html("</td><td class='right'>"); |
182 | cgit_print_date(info->committer_date); | 182 | cgit_print_date(info->committer_date); |
183 | html("</td></tr>\n"); | 183 | html("</td></tr>\n"); |
184 | html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); | 184 | html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); |
185 | query = fmt("h=%s&id=%s", sha1_to_hex(commit->object.sha1), | 185 | query = fmt("h=%s&id=%s", sha1_to_hex(commit->object.sha1), |
186 | sha1_to_hex(commit->tree->object.sha1)); | 186 | sha1_to_hex(commit->tree->object.sha1)); |
187 | html_attr(cgit_pageurl(cgit_query_repo, "tree", query)); | 187 | html_attr(cgit_pageurl(cgit_query_repo, "tree", query)); |
188 | htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); | 188 | htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); |
189 | for (p = commit->parents; p ; p = p->next) { | 189 | for (p = commit->parents; p ; p = p->next) { |
190 | parent = lookup_commit_reference(p->item->object.sha1); | 190 | parent = lookup_commit_reference(p->item->object.sha1); |
191 | if (!parent) { | 191 | if (!parent) { |
192 | html("<tr><td colspan='3'>"); | 192 | html("<tr><td colspan='3'>"); |
193 | cgit_print_error("Error reading parent commit"); | 193 | cgit_print_error("Error reading parent commit"); |
194 | html("</td></tr>"); | 194 | html("</td></tr>"); |
195 | continue; | 195 | continue; |
196 | } | 196 | } |
197 | html("<tr><th>parent</th>" | 197 | html("<tr><th>parent</th>" |
198 | "<td colspan='2' class='sha1'>" | 198 | "<td colspan='2' class='sha1'>" |
199 | "<a href='"); | 199 | "<a href='"); |
200 | query = fmt("h=%s", sha1_to_hex(p->item->object.sha1)); | 200 | query = fmt("h=%s", sha1_to_hex(p->item->object.sha1)); |
201 | html_attr(cgit_pageurl(cgit_query_repo, "commit", query)); | 201 | html_attr(cgit_pageurl(cgit_query_repo, "commit", query)); |
202 | htmlf("'>%s</a> (<a href='", | 202 | htmlf("'>%s</a> (<a href='", |
203 | sha1_to_hex(p->item->object.sha1)); | 203 | sha1_to_hex(p->item->object.sha1)); |
204 | query = fmt("id=%s&id2=%s", sha1_to_hex(parent->tree->object.sha1), | 204 | query = fmt("id=%s&id2=%s", sha1_to_hex(parent->tree->object.sha1), |
205 | sha1_to_hex(commit->tree->object.sha1)); | 205 | sha1_to_hex(commit->tree->object.sha1)); |
206 | html_attr(cgit_pageurl(cgit_query_repo, "diff", query)); | 206 | html_attr(cgit_pageurl(cgit_query_repo, "diff", query)); |
207 | html("'>diff</a>)</td></tr>"); | 207 | html("'>diff</a>)</td></tr>"); |
208 | } | 208 | } |
209 | if (cgit_repo->snapshots) { | 209 | if (cgit_repo->snapshots) { |
210 | htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); | 210 | htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); |
211 | filename = fmt("%s-%s.zip", cgit_query_repo, hex); | 211 | filename = fmt("%s-%s.zip", cgit_query_repo, hex); |
212 | html_attr(cgit_pageurl(cgit_query_repo, "snapshot", | 212 | html_attr(cgit_pageurl(cgit_query_repo, "snapshot", |
213 | fmt("id=%s&name=%s", hex, filename))); | 213 | fmt("id=%s&name=%s", hex, filename))); |
214 | htmlf("'>%s</a></td></tr>", filename); | 214 | htmlf("'>%s</a></td></tr>", filename); |
215 | } | 215 | } |
216 | html("</table>\n"); | 216 | html("</table>\n"); |
217 | html("<div class='commit-subject'>"); | 217 | html("<div class='commit-subject'>"); |
218 | html_txt(info->subject); | 218 | html_txt(info->subject); |
219 | html("</div>"); | 219 | html("</div>"); |
220 | html("<div class='commit-msg'>"); | 220 | html("<div class='commit-msg'>"); |
221 | html_txt(info->msg); | 221 | html_txt(info->msg); |
222 | html("</div>"); | 222 | html("</div>"); |
223 | if (!(commit->parents && commit->parents->next && commit->parents->next->next)) { | 223 | if (!(commit->parents && commit->parents->next && commit->parents->next->next)) { |
224 | html("<div class='diffstat-header'>Diffstat</div>"); | ||
224 | html("<table class='diffstat'>"); | 225 | html("<table class='diffstat'>"); |
225 | max_changes = 0; | 226 | max_changes = 0; |
226 | cgit_diff_commit(commit, inspect_filepair); | 227 | cgit_diff_commit(commit, inspect_filepair); |
227 | for(i = 0; i<files; i++) | 228 | for(i = 0; i<files; i++) |
228 | print_fileinfo(&items[i]); | 229 | print_fileinfo(&items[i]); |
229 | html("</table>"); | 230 | html("</table>"); |
230 | html("<div class='diffstat-summary'>"); | 231 | html("<div class='diffstat-summary'>"); |
231 | htmlf("%d files changed, %d insertions, %d deletions\n", | 232 | htmlf("%d files changed, %d insertions, %d deletions (", |
232 | files, total_adds, total_rems); | 233 | files, total_adds, total_rems); |
234 | query = fmt("h=%s", hex); | ||
235 | html_link_open(cgit_pageurl(cgit_query_repo, "diff", query), NULL, NULL); | ||
236 | html("show diff</a>)"); | ||
233 | html("</div>"); | 237 | html("</div>"); |
234 | } | 238 | } |
235 | cgit_free_commitinfo(info); | 239 | cgit_free_commitinfo(info); |
236 | } | 240 | } |