Diffstat (limited to 'ui-diff.c')
| -rw-r--r-- | ui-diff.c | 81 |
1 files changed, 4 insertions, 77 deletions
@@ -366,21 +366,6 @@ static void cgit_print_ref_select(const char *name, const char *selected) html("</select>"); } -/* - * The number of commits to step back from the selected ref, so that any - * ancestor of a branch or tag can be picked without typing a rev into - * the url by hand. - */ -static void cgit_print_ref_offset(const char *name, int value) -{ - html(" <input type='text' size='2' name='"); - html_attr(name); - html("' title='N commits back from the selected ref'"); - if (value) - htmlf(" value='%d'", value); - html("> <span class='hint'>back</span>"); -} - void cgit_print_diff_ctrls(void) { int i, curr; @@ -412,61 +397,17 @@ void cgit_print_diff_ctrls(void) /* ref pickers: compare any two refs (branches/tags) */ { - const char *new_ref = ctx.qry.oid && *ctx.qry.oid ? - ctx.qry.oid : ctx.qry.head; + const char *new_ref = ctx.qry.oid ? ctx.qry.oid : ctx.qry.head; const char *old_ref = ctx.qry.oid2; - const char *disp_old_ref; - int idoff = ctx.qry.idoff; - int id2off = ctx.qry.id2off; - int disp_id2off; - - if (old_ref && *old_ref) { - disp_old_ref = old_ref; - disp_id2off = id2off; - } else if (!is_null_oid(old_rev_oid)) { - /* - * No from ref given: the diff compares the (stepped) - * to rev against its parent, i.e. new_ref~(idoff+1); - * show that instead of leaving the picker empty. Keep - * the ref name rather than a materialized parent sha. - */ - disp_old_ref = new_ref; - disp_id2off = idoff + 1; - } else { - /* to rev is the root: diff against the empty tree */ - disp_old_ref = NULL; - disp_id2off = 0; - } html("<tr>"); html("<td class='label'>from:</td>"); html("<td class='ctrl'>"); - cgit_print_ref_select("id2", disp_old_ref); - cgit_print_ref_offset("id2off", disp_id2off); + cgit_print_ref_select("id2", old_ref); html("</td></tr><tr>"); html("<td class='label'>to:</td>"); html("<td class='ctrl'>"); cgit_print_ref_select("id", new_ref); - cgit_print_ref_offset("idoff", ctx.qry.idoff); - html("</td></tr>"); - - html("<tr><td/><td class='ctrl'>"); - html("<input type='submit' value='apply'>"); - html(" | "); - /* - * The flip link swaps the displayed refs, so the displayed - * from ref becomes the to ref. cgit_diff_link() emits the - * offsets from ctx.qry; swap them around the call so they - * follow the refs. - */ - ctx.qry.idoff = disp_id2off; - ctx.qry.id2off = idoff; - cgit_diff_link("flip", "swap from and to", "button", - ctx.qry.head, - disp_old_ref, new_ref, - ctx.qry.path); - ctx.qry.idoff = idoff; - ctx.qry.id2off = id2off; html("</td></tr>"); } html("</table>"); @@ -519,7 +460,6 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, { struct commit *commit, *commit2; const struct object_id *old_tree_oid, *new_tree_oid; - struct strbuf new_refbuf = STRBUF_INIT, old_refbuf = STRBUF_INIT; diff_type difftype; /* @@ -534,16 +474,8 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, current_prefix = NULL; } - /* - * An empty rev is the same as no rev; a zero offset means the ref - * itself. - */ - if (!new_rev || !*new_rev) + if (!new_rev) new_rev = ctx.qry.head; - if (ctx.qry.idoff) { - strbuf_addf(&new_refbuf, "%s~%d", new_rev, ctx.qry.idoff); - new_rev = new_refbuf.buf; - } if (repo_get_oid(the_repository, new_rev, new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", new_rev); @@ -557,12 +489,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, } new_tree_oid = get_commit_tree_oid(commit); - if (old_rev && *old_rev) { - if (ctx.qry.id2off) { - strbuf_addf(&old_refbuf, "%s~%d", old_rev, - ctx.qry.id2off); - old_rev = old_refbuf.buf; - } + if (old_rev) { if (repo_get_oid(the_repository, old_rev, old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", old_rev); |