summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-06-29 18:27:41 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-06-29 18:31:00 (UTC)
commit103940fe6b0914dc42b8b033d1d328f38135ca5f (patch) (unidiff)
tree2bc9c831dc5158032e68e065519e7ee243b6731d
parent382805ee83b6e6f165159312a9fe20e3971897b6 (diff)
downloadcgit-103940fe6b0914dc42b8b033d1d328f38135ca5f.zip
cgit-103940fe6b0914dc42b8b033d1d328f38135ca5f.tar.gz
cgit-103940fe6b0914dc42b8b033d1d328f38135ca5f.tar.bz2
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>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h2
-rw-r--r--ui-log.c16
-rw-r--r--ui-repolist.c2
-rw-r--r--ui-shared.c22
-rw-r--r--ui-summary.c2
-rw-r--r--ui-tree.c2
6 files changed, 30 insertions, 16 deletions
diff --git a/cgit.h b/cgit.h
index ddb2fff..a59a370 100644
--- a/cgit.h
+++ b/cgit.h
@@ -207,5 +207,5 @@ extern void cgit_tree_link(char *name, char *title, char *class, char *head,
207 char *rev, char *path); 207 char *rev, char *path);
208extern void cgit_log_link(char *name, char *title, char *class, char *head, 208extern void cgit_log_link(char *name, char *title, char *class, char *head,
209 char *rev, char *path); 209 char *rev, char *path, int ofs);
210extern void cgit_commit_link(char *name, char *title, char *class, char *head, 210extern void cgit_commit_link(char *name, char *title, char *class, char *head,
211 char *rev); 211 char *rev);
diff --git a/ui-log.c b/ui-log.c
index 95cb453..d38e40a 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -114,15 +114,13 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, i
114 html("<div class='pager'>"); 114 html("<div class='pager'>");
115 if (ofs > 0) { 115 if (ofs > 0) {
116 html("&nbsp;<a href='"); 116 cgit_log_link("[prev]", NULL, NULL, cgit_query_head,
117 html(cgit_pageurl(cgit_query_repo, cgit_query_page, 117 cgit_query_sha1, cgit_query_path,
118 fmt("h=%s&amp;ofs=%d", tip, ofs-cnt))); 118 ofs - cnt);
119 html("'>[prev]</a>&nbsp;"); 119 html("&nbsp;");
120 } 120 }
121
122 if ((commit = get_revision(&rev)) != NULL) { 121 if ((commit = get_revision(&rev)) != NULL) {
123 html("&nbsp;<a href='"); 122 cgit_log_link("[next]", NULL, NULL, cgit_query_head,
124 html(cgit_pageurl(cgit_query_repo, "log", 123 cgit_query_sha1, cgit_query_path,
125 fmt("h=%s&amp;ofs=%d", tip, ofs+cnt))); 124 ofs + cnt);
126 html("'>[next]</a>&nbsp;");
127 } 125 }
128 html("</div>"); 126 html("</div>");
diff --git a/ui-repolist.c b/ui-repolist.c
index c735368..4c86543 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -99,5 +99,5 @@ void cgit_print_repolist(struct cacheitem *item)
99 NULL, "button"); 99 NULL, "button");
100 html("summary</a>"); 100 html("summary</a>");
101 cgit_log_link("log", NULL, "button", NULL, NULL, NULL); 101 cgit_log_link("log", NULL, "button", NULL, NULL, NULL, 0);
102 cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); 102 cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
103 html("</td>"); 103 html("</td>");
diff --git a/ui-shared.c b/ui-shared.c
index 64c237f..bfcc2ac 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -164,7 +164,23 @@ void cgit_tree_link(char *name, char *title, char *class, char *head,
164 164
165void cgit_log_link(char *name, char *title, char *class, char *head, 165void cgit_log_link(char *name, char *title, char *class, char *head,
166 char *rev, char *path) 166 char *rev, char *path, int ofs)
167{ 167{
168 reporevlink("log", name, title, class, head, rev, path); 168 char *delim;
169
170 delim = repolink(title, class, "log", head, path);
171 if (rev && strcmp(rev, cgit_query_head)) {
172 html(delim);
173 html("id=");
174 html_attr(rev);
175 delim = "&";
176 }
177 if (ofs > 0) {
178 html(delim);
179 html("ofs=");
180 htmlf("%d", ofs);
181 }
182 html("'>");
183 html_txt(name);
184 html("</a>");
169} 185}
170 186
@@ -303,5 +319,5 @@ void cgit_print_pageheader(char *title, int show_search)
303 html(" "); 319 html(" ");
304 cgit_log_link("log", NULL, NULL, cgit_query_head, 320 cgit_log_link("log", NULL, NULL, cgit_query_head,
305 cgit_query_sha1, cgit_query_path); 321 cgit_query_sha1, cgit_query_path, 0);
306 html(" "); 322 html(" ");
307 cgit_tree_link("tree", NULL, NULL, cgit_query_head, 323 cgit_tree_link("tree", NULL, NULL, cgit_query_head,
diff --git a/ui-summary.c b/ui-summary.c
index 03dd078..b4bc6d8 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -28,5 +28,5 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
28 info = cgit_parse_commit(commit); 28 info = cgit_parse_commit(commit);
29 html("<tr><td>"); 29 html("<tr><td>");
30 cgit_log_link(ref, NULL, NULL, ref, NULL, NULL); 30 cgit_log_link(ref, NULL, NULL, ref, NULL, NULL, 0);
31 html("</td><td>"); 31 html("</td><td>");
32 cgit_print_age(commit->date, -1, NULL); 32 cgit_print_age(commit->date, -1, NULL);
diff --git a/ui-tree.c b/ui-tree.c
index b6cb813..c5d64ff 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -94,5 +94,5 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
94 html("<td>"); 94 html("<td>");
95 cgit_log_link("log", NULL, "button", cgit_query_head, curr_rev, 95 cgit_log_link("log", NULL, "button", cgit_query_head, curr_rev,
96 fullpath); 96 fullpath, 0);
97 html("</td></tr>\n"); 97 html("</td></tr>\n");
98 free(name); 98 free(name);