aboutsummaryrefslogtreecommitdiffstats
path: root/ui-blame.c
diff options
context:
space:
mode:
authorJeff Smith2017-10-17 23:17:34 -0500
committerJason A. Donenfeld2018-01-19 11:40:55 +0100
commitaafc42d8089437db5105feb12d540c33fe9f9e16 (patch)
tree1d30014cd12b5b4136b8555092355f07acb206c4 /ui-blame.c
parent2b95c9d49c8581e2b19efca1613ada292f56bf08 (diff)
downloadcgit-aafc42d8089437db5105feb12d540c33fe9f9e16.tar.gz
cgit-aafc42d8089437db5105feb12d540c33fe9f9e16.tar.bz2
cgit-aafc42d8089437db5105feb12d540c33fe9f9e16.zip
ui-blame: Make each column into a single table cell
Signed-off-by: Jeff Smith <whydoubt@gmail.com> Reviewed-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-blame.c')
-rw-r--r--ui-blame.c58
1 files changed, 37 insertions, 21 deletions
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