about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cgit.css19
-rw-r--r--ui-blame.c58
2 files changed, 54 insertions, 23 deletions
diff --git a/cgit.css b/cgit.css index 893ebeb..20b7e86 100644 --- a/cgit.css +++ b/cgit.css
@@ -330,11 +330,26 @@ div#cgit table.ssdiff td.lineno a:hover {
330 color: black; 330 color: black;
331} 331}
332 332
333div#cgit table.blame tr:nth-child(even) { 333div#cgit table.blame td.hashes,
334div#cgit table.blame td.lines,
335div#cgit table.blame td.linenumbers {
336 padding: 0;
337}
338
339div#cgit table.blame td.hashes div.alt,
340div#cgit table.blame td.lines div.alt {
341 padding: 0 0.5em 0 0.5em;
342}
343
344div#cgit table.blame td.linenumbers div.alt {
345 padding: 0 0.5em 0 0;
346}
347
348div#cgit table.blame div.alt:nth-child(even) {
334 background: #eee; 349 background: #eee;
335} 350}
336 351
337div#cgit table.blame tr:nth-child(odd) { 352div#cgit table.blame div.alt:nth-child(odd) {
338 background: white; 353 background: white;
339} 354}
340 355
diff --git a/ui-blame.c b/ui-blame.c index bbaad1c..d565fff 100644 --- a/ui-blame.c +++ b/ui-blame.c
@@ -45,11 +45,17 @@ static void emit_blame_entry_hash(struct blame_entry *ent)
45{ 45{
46 struct blame_origin *suspect = ent->suspect; 46 struct blame_origin *suspect = ent->suspect;
47 struct object_id *oid = &suspect->commit->object.oid; 47 struct object_id *oid = &suspect->commit->object.oid;
48 unsigned long line = 0;
48 49
49 char *detail = emit_suspect_detail(suspect); 50 char *detail = emit_suspect_detail(suspect);
51 html("<span class='sha1'>");
50 cgit_commit_link(find_unique_abbrev(oid->hash, DEFAULT_ABBREV), detail, 52 cgit_commit_link(find_unique_abbrev(oid->hash, DEFAULT_ABBREV), detail,
51 NULL, ctx.qry.head, oid_to_hex(oid), suspect->path); 53 NULL, ctx.qry.head, oid_to_hex(oid), suspect->path);
54 html("</span>");
52 free(detail); 55 free(detail);
56
57 while (line++ < ent->num_lines)
58 html("\n");
53} 59}
54 60
55static void emit_blame_entry_linenumber(struct blame_entry *ent) 61static void emit_blame_entry_linenumber(struct blame_entry *ent)
@@ -72,24 +78,6 @@ static void emit_blame_entry_line(struct blame_scoreboard *sb,
72 html_ntxt(cp, cpend - cp); 78 html_ntxt(cp, cpend - cp);
73} 79}
74 80
75static void emit_blame_entry(struct blame_scoreboard *sb,
76 struct blame_entry *ent)
77{
78 html("<tr><td class='sha1 hashes'>");
79 emit_blame_entry_hash(ent);
80 html("</td>\n");
81
82 if (ctx.cfg.enable_tree_linenumbers) {
83 html("<td class='linenumbers'><pre>");
84 emit_blame_entry_linenumber(ent);
85 html("</pre></td>\n");
86 }
87
88 html("<td class='lines'><pre><code>");
89 emit_blame_entry_line(sb, ent);
90 html("</code></pre></td></tr>\n");
91}
92
93struct walk_tree_context { 81struct walk_tree_context {
94 char *curr_rev; 82 char *curr_rev;
95 int match_baselen; 83 int match_baselen;
@@ -147,16 +135,44 @@ static void print_object(const unsigned char *sha1, const char *path,
147 return; 135 return;
148 } 136 }
149 137
150 html("<table class='blame blob'>"); 138 html("<table class='blame blob'>\n<tr>\n");
139
140 /* Commit hashes */
141 html("<td class='hashes'>");
142 for (ent = sb.ent; ent; ent = ent->next) {
143 html("<div class='alt'><pre>");
144 emit_blame_entry_hash(ent);
145 html("</pre></div>");
146 }
147 html("</td>\n");
148
149 /* Line numbers */
150 if (ctx.cfg.enable_tree_linenumbers) {
151 html("<td class='linenumbers'>");
152 for (ent = sb.ent; ent; ent = ent->next) {
153 html("<div class='alt'><pre>");
154 emit_blame_entry_linenumber(ent);
155 html("</pre></div>");
156 }
157 html("</td>\n");
158 }
159
160 /* Lines */
161 html("<td class='lines'>");
151 for (ent = sb.ent; ent; ) { 162 for (ent = sb.ent; ent; ) {
152 struct blame_entry *e = ent->next; 163 struct blame_entry *e = ent->next;
153 emit_blame_entry(&sb, ent); 164 html("<div class='alt'><pre><code>");
165 emit_blame_entry_line(&sb, ent);
166 html("</code></pre></div>");
154 free(ent); 167 free(ent);
155 ent = e; 168 ent = e;
156 } 169 }
157 html("</table>\n"); 170 html("</td>\n");
171
158 free((void *)sb.final_buf); 172 free((void *)sb.final_buf);
159 173
174 html("</tr>\n</table>\n");
175
160 cgit_print_layout_end(); 176 cgit_print_layout_end();
161} 177}
162 178