Add ofs argument to cgit_log_link and use it in ui-log.c

This fixes a bug in the prev/next links on the log page: when on the default
branch the links to prev/next page would contain h=(null).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This commit is contained in:
Lars Hjemli 2007-06-29 20:27:41 +02:00
rodzic 382805ee83
commit 103940fe6b
6 zmienionych plików z 30 dodań i 16 usunięć

2
cgit.h
Wyświetl plik

@ -206,7 +206,7 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename,
extern void cgit_tree_link(char *name, char *title, char *class, char *head, extern void cgit_tree_link(char *name, char *title, char *class, char *head,
char *rev, char *path); char *rev, char *path);
extern void cgit_log_link(char *name, char *title, char *class, char *head, extern void cgit_log_link(char *name, char *title, char *class, char *head,
char *rev, char *path); char *rev, char *path, int ofs);
extern void cgit_commit_link(char *name, char *title, char *class, char *head, extern void cgit_commit_link(char *name, char *title, char *class, char *head,
char *rev); char *rev);
extern void cgit_diff_link(char *name, char *title, char *class, char *head, extern void cgit_diff_link(char *name, char *title, char *class, char *head,

Wyświetl plik

@ -113,17 +113,15 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, i
if (pager) { if (pager) {
html("<div class='pager'>"); html("<div class='pager'>");
if (ofs > 0) { if (ofs > 0) {
html("&nbsp;<a href='"); cgit_log_link("[prev]", NULL, NULL, cgit_query_head,
html(cgit_pageurl(cgit_query_repo, cgit_query_page, cgit_query_sha1, cgit_query_path,
fmt("h=%s&amp;ofs=%d", tip, ofs-cnt))); ofs - cnt);
html("'>[prev]</a>&nbsp;"); html("&nbsp;");
} }
if ((commit = get_revision(&rev)) != NULL) { if ((commit = get_revision(&rev)) != NULL) {
html("&nbsp;<a href='"); cgit_log_link("[next]", NULL, NULL, cgit_query_head,
html(cgit_pageurl(cgit_query_repo, "log", cgit_query_sha1, cgit_query_path,
fmt("h=%s&amp;ofs=%d", tip, ofs+cnt))); ofs + cnt);
html("'>[next]</a>&nbsp;");
} }
html("</div>"); html("</div>");
} }

Wyświetl plik

@ -98,7 +98,7 @@ void cgit_print_repolist(struct cacheitem *item)
html_link_open(cgit_repourl(cgit_repo->url), html_link_open(cgit_repourl(cgit_repo->url),
NULL, "button"); NULL, "button");
html("summary</a>"); html("summary</a>");
cgit_log_link("log", NULL, "button", NULL, NULL, NULL); cgit_log_link("log", NULL, "button", NULL, NULL, NULL, 0);
cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
html("</td>"); html("</td>");
} }

Wyświetl plik

@ -163,9 +163,25 @@ void cgit_tree_link(char *name, char *title, char *class, char *head,
} }
void cgit_log_link(char *name, char *title, char *class, char *head, void cgit_log_link(char *name, char *title, char *class, char *head,
char *rev, char *path) char *rev, char *path, int ofs)
{ {
reporevlink("log", name, title, class, head, rev, path); char *delim;
delim = repolink(title, class, "log", head, path);
if (rev && strcmp(rev, cgit_query_head)) {
html(delim);
html("id=");
html_attr(rev);
delim = "&";
}
if (ofs > 0) {
html(delim);
html("ofs=");
htmlf("%d", ofs);
}
html("'>");
html_txt(name);
html("</a>");
} }
void cgit_commit_link(char *name, char *title, char *class, char *head, void cgit_commit_link(char *name, char *title, char *class, char *head,
@ -302,7 +318,7 @@ void cgit_print_pageheader(char *title, int show_search)
NULL, NULL); NULL, NULL);
html(" "); html(" ");
cgit_log_link("log", NULL, NULL, cgit_query_head, cgit_log_link("log", NULL, NULL, cgit_query_head,
cgit_query_sha1, cgit_query_path); cgit_query_sha1, cgit_query_path, 0);
html(" "); html(" ");
cgit_tree_link("tree", NULL, NULL, cgit_query_head, cgit_tree_link("tree", NULL, NULL, cgit_query_head,
cgit_query_sha1, NULL); cgit_query_sha1, NULL);

Wyświetl plik

@ -27,7 +27,7 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
if (commit && !parse_commit(commit)){ if (commit && !parse_commit(commit)){
info = cgit_parse_commit(commit); info = cgit_parse_commit(commit);
html("<tr><td>"); html("<tr><td>");
cgit_log_link(ref, NULL, NULL, ref, NULL, NULL); cgit_log_link(ref, NULL, NULL, ref, NULL, NULL, 0);
html("</td><td>"); html("</td><td>");
cgit_print_age(commit->date, -1, NULL); cgit_print_age(commit->date, -1, NULL);
html("</td><td>"); html("</td><td>");

Wyświetl plik

@ -93,7 +93,7 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
html("<td>"); html("<td>");
cgit_log_link("log", NULL, "button", cgit_query_head, curr_rev, cgit_log_link("log", NULL, "button", cgit_query_head, curr_rev,
fullpath); fullpath, 0);
html("</td></tr>\n"); html("</td></tr>\n");
free(name); free(name);
return 0; return 0;