aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lars Hjemli <hjemli@gmail.com>2007-06-30 03:27:41 (JST)
committerGravatar Lars Hjemli <hjemli@gmail.com>2007-06-30 03:31:00 (JST)
commit103940fe6b0914dc42b8b033d1d328f38135ca5f (patch)
tree2bc9c831dc5158032e68e065519e7ee243b6731d
parent382805ee83b6e6f165159312a9fe20e3971897b6 (diff)
downloadcgit-103940fe6b0914dc42b8b033d1d328f38135ca5f.zip
cgit-103940fe6b0914dc42b8b033d1d328f38135ca5f.tar.gz
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>
-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
@@ -206,7 +206,7 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename,
206extern void cgit_tree_link(char *name, char *title, char *class, char *head, 206extern 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);
212extern void cgit_diff_link(char *name, char *title, char *class, char *head, 212extern void cgit_diff_link(char *name, char *title, char *class, char *head,
diff --git a/ui-log.c b/ui-log.c
index 95cb453..d38e40a 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -113,17 +113,15 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, i
113 if (pager) { 113 if (pager) {
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>");
129 } 127 }
diff --git a/ui-repolist.c b/ui-repolist.c
index c735368..4c86543 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -98,7 +98,7 @@ void cgit_print_repolist(struct cacheitem *item)
98 html_link_open(cgit_repourl(cgit_repo->url), 98 html_link_open(cgit_repourl(cgit_repo->url),
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>");
104 } 104 }
diff --git a/ui-shared.c b/ui-shared.c
index 64c237f..bfcc2ac 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -163,9 +163,25 @@ void cgit_tree_link(char *name, char *title, char *class, char *head,
163} 163}
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
171void cgit_commit_link(char *name, char *title, char *class, char *head, 187void cgit_commit_link(char *name, char *title, char *class, char *head,
@@ -302,7 +318,7 @@ void cgit_print_pageheader(char *title, int show_search)
302 NULL, NULL); 318 NULL, NULL);
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,
308 cgit_query_sha1, NULL); 324 cgit_query_sha1, NULL);
diff --git a/ui-summary.c b/ui-summary.c
index 03dd078..b4bc6d8 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -27,7 +27,7 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
27 if (commit && !parse_commit(commit)){ 27 if (commit && !parse_commit(commit)){
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);
33 html("</td><td>"); 33 html("</td><td>");
diff --git a/ui-tree.c b/ui-tree.c
index b6cb813..c5d64ff 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -93,7 +93,7 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
93 93
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);
99 return 0; 99 return 0;