diff options
Diffstat (limited to 'ui-blame.c')
-rw-r--r-- | ui-blame.c | 58 |
1 files changed, 37 insertions, 21 deletions
@@ -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 | ||
55 | static void emit_blame_entry_linenumber(struct blame_entry *ent) | 61 | static 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 | ||
75 | static 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 | |||
93 | struct walk_tree_context { | 81 | struct 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 | ||