diff options
Diffstat (limited to 'source/ui-diff.c')
| -rw-r--r-- | source/ui-diff.c | 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 39 insertions, 32 deletions
diff --git a/source/ui-diff.c b/source/ui-diff.c index f258e9f..5c9cd1c 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -234,6 +234,13 @@ static void print_file_header(const struct object_id *old_oid, char *old_path, u int subproject; subproject = (S_ISGITLINK(old_mode) || S_ISGITLINK(new_mode)); + // The side by side view opens its file group before the header row, + // so only the unified view opens one here. + if (!use_ssdiff) { + html("<div class='file' data-path='"); + html_attr(new_path); + html("'>"); + } html("<div class='head'>"); html("diff --git a/"); html_txt(old_path); @@ -282,6 +289,20 @@ static void print_file_header(const struct object_id *old_oid, char *old_path, u } /* + * Closes the group print_file_header or cgit_ssdiff_header_begin opened. The + * side by side footer closes its own, so the unified view is the only one with + * work to do here. + */ +static void end_file(void) +{ + // The unified table keeps its whitespace, so no newline follows. + if (use_ssdiff) + cgit_ssdiff_footer(); + else + html("</div>"); +} + +/* * The length passed counts the terminator, because a renderer strips the last * byte of every line it is given. */ @@ -315,12 +336,11 @@ static void print_truncated(const char *path) cgit_diff_link("View it on its own page", NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, path); html("."); - if (use_ssdiff) { + if (use_ssdiff) html("</td></tr>"); - cgit_ssdiff_footer(); - } else { + else html("</div>"); - } + end_file(); } static struct fileinfo *reserve_item(void) @@ -353,7 +373,7 @@ static void collect_body(struct diff_filepair *pair, struct fileinfo *item, int html_capture_begin(body); if (use_ssdiff) - cgit_ssdiff_header_begin(); + cgit_ssdiff_header_begin(pair->two->path); print_file_header(&pair->one->oid, pair->one->path, pair->one->mode, &pair->two->oid, pair->two->path, pair->two->mode); if (use_ssdiff) @@ -383,8 +403,7 @@ static void collect_body(struct diff_filepair *pair, struct fileinfo *item, int if (*binary) print_binary_differs(); } - if (use_ssdiff) - cgit_ssdiff_footer(); + end_file(); if (render_suppressed) { // Setting the length back would keep the grown allocation, @@ -491,7 +510,7 @@ static void filepair_cb(struct diff_filepair *pair) idx = item_idx++; current_filepair = pair; if (use_ssdiff) { - cgit_ssdiff_header_begin(); + cgit_ssdiff_header_begin(pair->two->path); line_fn = cgit_ssdiff_line_cb; } print_file_header(&pair->one->oid, pair->one->path, pair->one->mode, @@ -505,8 +524,7 @@ static void filepair_cb(struct diff_filepair *pair) } if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { print_subproject_lines(pair, line_fn); - if (use_ssdiff) - cgit_ssdiff_footer(); + end_file(); return; } if (cgit_diff_files(&pair->one->oid, &pair->two->oid, &old_size, &new_size, @@ -514,8 +532,7 @@ static void filepair_cb(struct diff_filepair *pair) cgit_print_error("Error running diff"); if (binary) print_binary_differs(); - if (use_ssdiff) - cgit_ssdiff_footer(); + end_file(); } static void print_raw_patch(const struct object_id *old_tree_oid, const struct object_id *new_tree_oid) @@ -553,14 +570,11 @@ void cgit_print_diff_ctrls(void) html("<div class='cgit-panel'>\n"); html("<strong>diff options</strong>"); - html("<form method='get'>"); + html("<form method='get' aria-label='Diff options'>"); cgit_add_hidden_formfields(1, 0, ctx.qry.page); - html("<table>"); - html("<tr><td colspan='2'></td></tr>"); - html("<tr>"); - html("<td class='label'>context:</td>"); - html("<td class='ctrl'>"); - html("<select name='context'>"); + html("<div class='fields'>"); + html("<label for='diff-context'>context:</label>"); + html("<select id='diff-context' name='context'>"); selected = ctx.qry.context; if (!selected) selected = DEFAULT_DIFF_CONTEXT; @@ -569,27 +583,20 @@ void cgit_print_diff_ctrls(void) for (i = 15; i <= MAX_DIFF_CONTEXT_LINES; i += 5) html_intoption(i, cgit_fmt("%d", i), selected); html("</select>"); - html("</td>"); - html("</tr><tr>"); - html("<td class='label'>space:</td>"); - html("<td class='ctrl'>"); - html("<select name='ignorews'>"); + html("<label for='diff-space'>space:</label>"); + html("<select id='diff-space' name='ignorews'>"); html_intoption(0, "include", ctx.qry.ignorews); html_intoption(1, "ignore", ctx.qry.ignorews); html("</select>"); - html("</td>"); - html("</tr><tr>"); - html("<td class='label'>mode:</td>"); - html("<td class='ctrl'>"); - html("<select name='dt'>"); + html("<label for='diff-mode'>mode:</label>"); + html("<select id='diff-mode' name='dt'>"); selected = ctx.qry.has_difftype ? ctx.qry.difftype : ctx.cfg.difftype; html_intoption(0, "unified", selected); html_intoption(1, "ssdiff", selected); html_intoption(2, "stat only", selected); - html("</select></td></tr>"); - html("<tr><td></td><td class='ctrl'>"); + html("</select>"); html("<input type='submit' value='reload'>"); - html("</td></tr></table>"); + html("</div>"); html("</form>\n"); html("</div>\n"); } |
