summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorLars Hjemli <hjemli@gmail.com>2007-06-17 11:57:51 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-06-17 11:57:51 (UTC)
commit48c487d72daef7e71683a85f775db8d36ab20341 (patch) (unidiff)
tree8770334d7c77bd3e81f42ee12550e6db5febd4d2 /ui-shared.c
parent426032f767763b46f462de51d1ebded34f671d79 (diff)
downloadcgit-48c487d72daef7e71683a85f775db8d36ab20341.zip
cgit-48c487d72daef7e71683a85f775db8d36ab20341.tar.gz
cgit-48c487d72daef7e71683a85f775db8d36ab20341.tar.bz2
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>
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 657e8af..64ee79c 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -124,37 +124,49 @@ static char *repolink(char *title, char *class, char *page, char *head,
124 html(page); 124 html(page);
125 html("/"); 125 html("/");
126 if (path) 126 if (path)
127 html_attr(path); 127 html_attr(path);
128 delim = "&amp;"; 128 delim = "&amp;";
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);
134 delim = "&amp;"; 134 delim = "&amp;";
135 } 135 }
136 return fmt("%s", delim); 136 return fmt("%s", delim);
137} 137}
138 138
139void cgit_tree_link(char *name, char *title, char *class, char *head, 139static 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=");
148 html_attr(rev); 148 html_attr(rev);
149 } 149 }
150 html("'>"); 150 html("'>");
151 html_txt(name); 151 html_txt(name);
152 html("</a>"); 152 html("</a>");
153} 153}
154 154
155void 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
161void 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
155void cgit_print_date(time_t secs, char *format) 167void cgit_print_date(time_t secs, char *format)
156{ 168{
157 char buf[64]; 169 char buf[64];
158 struct tm *time; 170 struct tm *time;
159 171
160 time = gmtime(&secs); 172 time = gmtime(&secs);