diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Page a followed log by the name asked for
Each row of a followed log moves ctx.qry.vpath to the name its commit knew the file by, and the pager built its links from that, so past a rename both links named the old file and led to an empty page.
-rw-r--r--source/ui-log.c11
-rwxr-xr-xtests/t0103-log.sh10
2 files changed, 15 insertions, 6 deletions
diff --git a/source/ui-log.c b/source/ui-log.c
index 8adc5ac..1ac9a77 100644
--- a/source/ui-log.c
+++ b/source/ui-log.c
@@ -367,9 +367,10 @@ static char *next_token(char **src)
/*
* Whether there is a page after this one is answered by pulling one more
- * commit off the walk.
+ * commit off the walk. The links carry the path as it was asked for, since a
+ * followed rename leaves ctx.qry.vpath at the name the last row's commit knew.
*/
-static void print_pager(struct rev_info *revs, int ofs, int cnt)
+static void print_pager(struct rev_info *revs, const char *path, int ofs, int cnt)
{
struct commit *more = get_revision(revs);
@@ -381,7 +382,7 @@ static void print_pager(struct rev_info *revs, int ofs, int cnt)
if (ofs > 0) {
html("<li>");
cgit_log_link(
- "[prev]", NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.vpath,
+ "[prev]", NULL, NULL, ctx.qry.head, ctx.qry.oid, path,
ofs - cnt, ctx.qry.grep, ctx.qry.search, ctx.qry.showmsg, ctx.qry.follow
);
html("</li>");
@@ -389,7 +390,7 @@ static void print_pager(struct rev_info *revs, int ofs, int cnt)
if (more) {
html("<li>");
cgit_log_link(
- "[next]", NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.vpath,
+ "[next]", NULL, NULL, ctx.qry.head, ctx.qry.oid, path,
ofs + cnt, ctx.qry.grep, ctx.qry.search, ctx.qry.showmsg, ctx.qry.follow
);
html("</li>");
@@ -616,7 +617,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
commit->parents = NULL;
}
if (pager) {
- print_pager(&rev, ofs, cnt);
+ print_pager(&rev, path, ofs, cnt);
cgit_print_layout_end();
} else {
if ((commit = get_revision(&rev))) {
diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh
index 08f9ddd..ed92a76 100755
--- a/tests/t0103-log.sh
+++ b/tests/t0103-log.sh
@@ -46,7 +46,8 @@ test_expect_success 'no links with space in arg' '! grep "q=commit 1" tmp'
test_expect_success 'commit 2 is not visible' '! grep "commit 2" tmp'
# Following a file diffs each commit for the name the file had there, so the
-# root commit that created it has to be diffed too.
+# root commit that created it has to be diffed too, and paging has to go on
+# asking about the name the visitor followed rather than the older one.
test_expect_success 'set up a renamed file to follow' '
test_create_repo repos/fol &&
(
@@ -83,4 +84,11 @@ test_expect_success 'a followed log reaches the root commit' '
grep ">create a<" tmp
'
+test_expect_success 'the pager of a followed log keeps the name followed' '
+ CGIT_CONFIG="$PWD/folrc" QUERY_STRING="url=fol/log/b.txt&follow=1&ofs=3" cgit >tmp &&
+ grep ">edit a 3<" tmp &&
+ grep "href=./fol/log/b.txt?follow=1.>\[prev\]" tmp &&
+ grep "href=./fol/log/b.txt?ofs=6&amp;follow=1.>\[next\]" tmp
+'
+
test_done