diff options
| author | 2007-06-17 20:57:51 (JST) | |
|---|---|---|
| committer | 2007-06-17 20:57:51 (JST) | |
| commit | 48c487d72daef7e71683a85f775db8d36ab20341 (patch) | |
| tree | 8770334d7c77bd3e81f42ee12550e6db5febd4d2 | |
| parent | 426032f767763b46f462de51d1ebded34f671d79 (diff) | |
| download | cgit-48c487d72daef7e71683a85f775db8d36ab20341.zip cgit-48c487d72daef7e71683a85f775db8d36ab20341.tar.gz | |
Add git_log_link() and fix bug in generic repolink function
The generic repolink function compared head with cgit_query_head, which
almost always would be the same pointer. The test now compares with
repo.defbranch, which is the wanted behavour.
Bug discovered while adding cgit_log_link(), so this commit also contain
that change.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
| -rw-r--r-- | cgit.h | 2 | ||||
| -rw-r--r-- | ui-repolist.c | 4 | ||||
| -rw-r--r-- | ui-shared.c | 20 | ||||
| -rw-r--r-- | ui-summary.c | 6 | ||||
| -rw-r--r-- | ui-tree.c | 12 |
5 files changed, 24 insertions, 20 deletions
| @@ -203,6 +203,8 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename, | |||
| 203 | 203 | ||
| 204 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, | 204 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
| 205 | char *rev, char *path); | 205 | char *rev, char *path); |
| 206 | extern void cgit_log_link(char *name, char *title, char *class, char *head, | ||
| 207 | char *rev, char *path); | ||
| 206 | 208 | ||
| 207 | extern void cgit_print_error(char *msg); | 209 | extern void cgit_print_error(char *msg); |
| 208 | extern void cgit_print_date(time_t secs, char *format); | 210 | extern void cgit_print_date(time_t secs, char *format); |
diff --git a/ui-repolist.c b/ui-repolist.c index 8ade91a..2018dab 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
| @@ -89,9 +89,7 @@ void cgit_print_repolist(struct cacheitem *item) | |||
| 89 | html_link_open(cgit_repourl(cgit_repo->url), | 89 | html_link_open(cgit_repourl(cgit_repo->url), |
| 90 | "Summary", "button"); | 90 | "Summary", "button"); |
| 91 | html("S</a>"); | 91 | html("S</a>"); |
| 92 | html_link_open(cgit_pageurl(cgit_repo->name, "log", NULL), | 92 | cgit_log_link("L", "Log", "button", NULL, NULL, NULL); |
| 93 | "Log", "button"); | ||
| 94 | html("L</a>"); | ||
| 95 | cgit_tree_link("F", "Files", "button", NULL, NULL, NULL); | 93 | cgit_tree_link("F", "Files", "button", NULL, NULL, NULL); |
| 96 | html("</td></tr>\n"); | 94 | html("</td></tr>\n"); |
| 97 | } | 95 | } |
diff --git a/ui-shared.c b/ui-shared.c index 657e8af..64ee79c 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
| @@ -127,7 +127,7 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
| 127 | html_attr(path); | 127 | html_attr(path); |
| 128 | delim = "&"; | 128 | delim = "&"; |
| 129 | } | 129 | } |
| 130 | if (head && strcmp(head, cgit_query_head)) { | 130 | if (head && strcmp(head, cgit_repo->defbranch)) { |
| 131 | html(delim); | 131 | html(delim); |
| 132 | html("h="); | 132 | html("h="); |
| 133 | html_attr(head); | 133 | html_attr(head); |
| @@ -136,12 +136,12 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
| 136 | return fmt("%s", delim); | 136 | return fmt("%s", delim); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 139 | static char *reporevlink(char *page, char *name, char *title, char *class, |
| 140 | char *rev, char *path) | 140 | char *head, char *rev, char *path) |
| 141 | { | 141 | { |
| 142 | char *delim; | 142 | char *delim; |
| 143 | 143 | ||
| 144 | delim = repolink(title, class, "tree", head, path); | 144 | delim = repolink(title, class, page, head, path); |
| 145 | if (rev && strcmp(rev, cgit_query_head)) { | 145 | if (rev && strcmp(rev, cgit_query_head)) { |
| 146 | html(delim); | 146 | html(delim); |
| 147 | html("id="); | 147 | html("id="); |
| @@ -152,6 +152,18 @@ void cgit_tree_link(char *name, char *title, char *class, char *head, | |||
| 152 | html("</a>"); | 152 | html("</a>"); |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | void cgit_tree_link(char *name, char *title, char *class, char *head, | ||
| 156 | char *rev, char *path) | ||
| 157 | { | ||
| 158 | reporevlink("tree", name, title, class, head, rev, path); | ||
| 159 | } | ||
| 160 | |||
| 161 | void cgit_log_link(char *name, char *title, char *class, char *head, | ||
| 162 | char *rev, char *path) | ||
| 163 | { | ||
| 164 | reporevlink("log", name, title, class, head, rev, path); | ||
| 165 | } | ||
| 166 | |||
| 155 | void cgit_print_date(time_t secs, char *format) | 167 | void cgit_print_date(time_t secs, char *format) |
| 156 | { | 168 | { |
| 157 | char buf[64]; | 169 | char buf[64]; |
diff --git a/ui-summary.c b/ui-summary.c index 4bda4c2..29b76e3 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
| @@ -25,11 +25,7 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | |||
| 25 | if (commit && !parse_commit(commit)){ | 25 | if (commit && !parse_commit(commit)){ |
| 26 | info = cgit_parse_commit(commit); | 26 | info = cgit_parse_commit(commit); |
| 27 | html("<tr><td>"); | 27 | html("<tr><td>"); |
| 28 | url = cgit_pageurl(cgit_query_repo, "log", | 28 | cgit_log_link(refname, NULL, NULL, refname, NULL, NULL); |
| 29 | fmt("h=%s", refname)); | ||
| 30 | html_link_open(url, NULL, NULL); | ||
| 31 | html_txt(buf); | ||
| 32 | html_link_close(); | ||
| 33 | html("</td><td>"); | 29 | html("</td><td>"); |
| 34 | cgit_print_age(commit->date, -1, NULL); | 30 | cgit_print_age(commit->date, -1, NULL); |
| 35 | html("</td><td>"); | 31 | html("</td><td>"); |
| @@ -92,14 +92,10 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, | |||
| 92 | } | 92 | } |
| 93 | htmlf("</td><td class='ls-size'>%li</td>", size); | 93 | htmlf("</td><td class='ls-size'>%li</td>", size); |
| 94 | 94 | ||
| 95 | html("<td><a href='"); | 95 | html("<td>"); |
| 96 | qry = fmt("h=%s&path=%s%s%s", curr_rev, | 96 | cgit_log_link("L", "Log", "button", cgit_query_head, curr_rev, |
| 97 | cgit_query_path ? cgit_query_path : "", | 97 | fullpath); |
| 98 | cgit_query_path ? "/" : "", pathname); | 98 | html("</td></tr>\n"); |
| 99 | url = cgit_pageurl(cgit_query_repo, "log", qry); | ||
| 100 | html_attr(url); | ||
| 101 | html("' title='Log' class='button'>L</a></td>"); | ||
| 102 | html("</tr>\n"); | ||
| 103 | free(name); | 99 | free(name); |
| 104 | return 0; | 100 | return 0; |
| 105 | } | 101 | } |
