From 3e40b846456e4efc06ece7180ef152e053114385 Mon Sep 17 00:00:00 2001 From: Saya Andy Date: Tue, 8 Sep 2026 00:11:57 +0700 Subject: diff: allow stepping back N commits from the selected refs The ref pickers can only select the exact ref that is shown. Add an offset input next to each picker (idoff and id2off), whose value is the number of commits to step back, so any ancestor of a branch or tag can be compared without typing a rev into the url by hand. An apply button submits the values typed there, since text inputs cannot be auto-submitted on their own; the flip link swaps the offsets along with the refs, and the file-level links carry them through. By default both offsets are empty, meaning the selected refs themselves. An empty ref submitted from the form is likewise treated as no ref instead of triggering a bad object name error. --- cgit.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cgit.c') diff --git a/cgit.c b/cgit.c index bb32dc7..ff4b8d9 100644 --- a/cgit.c +++ b/cgit.c @@ -393,6 +393,14 @@ static void querystring_cb(const char *name, const char *value) ctx.qry.ignorews = atoi(value); } else if (!strcmp(name, "follow")) { ctx.qry.follow = atoi(value); + } else if (!strcmp(name, "idoff")) { + ctx.qry.idoff = atoi(value); + if (ctx.qry.idoff < 0) + ctx.qry.idoff = 0; + } else if (!strcmp(name, "id2off")) { + ctx.qry.id2off = atoi(value); + if (ctx.qry.id2off < 0) + ctx.qry.id2off = 0; } } -- cgit v1.3.1+16