author | Lars Hjemli <hjemli@gmail.com> | 2009-11-07 18:10:58 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-11-07 18:10:58 (UTC) |
commit | 41934a3222cd3e5a5f214e4275929519c70d311d (patch) (unidiff) | |
tree | f938c5a2a595ce0b33bab53cd7d6872bfb8d62c5 /ui-refs.c | |
parent | e633ccf714eb423c4522924c3b611dac2e176c5e (diff) | |
download | cgit-41934a3222cd3e5a5f214e4275929519c70d311d.zip cgit-41934a3222cd3e5a5f214e4275929519c70d311d.tar.gz cgit-41934a3222cd3e5a5f214e4275929519c70d311d.tar.bz2 |
Add support for remote branches
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-refs.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -126,120 +126,122 @@ static int print_tag(struct refinfo *ref) | |||
126 | struct tag *tag; | 126 | struct tag *tag; |
127 | struct taginfo *info; | 127 | struct taginfo *info; |
128 | char *name = (char *)ref->refname; | 128 | char *name = (char *)ref->refname; |
129 | 129 | ||
130 | if (ref->object->type == OBJ_TAG) { | 130 | if (ref->object->type == OBJ_TAG) { |
131 | tag = (struct tag *)ref->object; | 131 | tag = (struct tag *)ref->object; |
132 | info = ref->tag; | 132 | info = ref->tag; |
133 | if (!tag || !info) | 133 | if (!tag || !info) |
134 | return 1; | 134 | return 1; |
135 | html("<tr><td>"); | 135 | html("<tr><td>"); |
136 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); | 136 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); |
137 | html("</td><td>"); | 137 | html("</td><td>"); |
138 | if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT)) | 138 | if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT)) |
139 | print_tag_downloads(ctx.repo, name); | 139 | print_tag_downloads(ctx.repo, name); |
140 | else | 140 | else |
141 | cgit_object_link(tag->tagged); | 141 | cgit_object_link(tag->tagged); |
142 | html("</td><td>"); | 142 | html("</td><td>"); |
143 | if (info->tagger) | 143 | if (info->tagger) |
144 | html(info->tagger); | 144 | html(info->tagger); |
145 | html("</td><td colspan='2'>"); | 145 | html("</td><td colspan='2'>"); |
146 | if (info->tagger_date > 0) | 146 | if (info->tagger_date > 0) |
147 | cgit_print_age(info->tagger_date, -1, NULL); | 147 | cgit_print_age(info->tagger_date, -1, NULL); |
148 | html("</td></tr>\n"); | 148 | html("</td></tr>\n"); |
149 | } else { | 149 | } else { |
150 | if (!header) | 150 | if (!header) |
151 | print_tag_header(); | 151 | print_tag_header(); |
152 | html("<tr><td>"); | 152 | html("<tr><td>"); |
153 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); | 153 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); |
154 | html("</td><td>"); | 154 | html("</td><td>"); |
155 | if (ctx.repo->snapshots && (ref->object->type == OBJ_COMMIT)) | 155 | if (ctx.repo->snapshots && (ref->object->type == OBJ_COMMIT)) |
156 | print_tag_downloads(ctx.repo, name); | 156 | print_tag_downloads(ctx.repo, name); |
157 | else | 157 | else |
158 | cgit_object_link(ref->object); | 158 | cgit_object_link(ref->object); |
159 | html("</td><td>"); | 159 | html("</td><td>"); |
160 | if (ref->object->type == OBJ_COMMIT) | 160 | if (ref->object->type == OBJ_COMMIT) |
161 | html(ref->commit->author); | 161 | html(ref->commit->author); |
162 | html("</td><td colspan='2'>"); | 162 | html("</td><td colspan='2'>"); |
163 | if (ref->object->type == OBJ_COMMIT) | 163 | if (ref->object->type == OBJ_COMMIT) |
164 | cgit_print_age(ref->commit->commit->date, -1, NULL); | 164 | cgit_print_age(ref->commit->commit->date, -1, NULL); |
165 | html("</td></tr>\n"); | 165 | html("</td></tr>\n"); |
166 | } | 166 | } |
167 | return 0; | 167 | return 0; |
168 | } | 168 | } |
169 | 169 | ||
170 | static void print_refs_link(char *path) | 170 | static void print_refs_link(char *path) |
171 | { | 171 | { |
172 | html("<tr class='nohover'><td colspan='4'>"); | 172 | html("<tr class='nohover'><td colspan='4'>"); |
173 | cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); | 173 | cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); |
174 | html("</td></tr>"); | 174 | html("</td></tr>"); |
175 | } | 175 | } |
176 | 176 | ||
177 | void cgit_print_branches(int maxcount) | 177 | void cgit_print_branches(int maxcount) |
178 | { | 178 | { |
179 | struct reflist list; | 179 | struct reflist list; |
180 | int i; | 180 | int i; |
181 | 181 | ||
182 | html("<tr class='nohover'><th class='left'>Branch</th>" | 182 | html("<tr class='nohover'><th class='left'>Branch</th>" |
183 | "<th class='left'>Commit message</th>" | 183 | "<th class='left'>Commit message</th>" |
184 | "<th class='left'>Author</th>" | 184 | "<th class='left'>Author</th>" |
185 | "<th class='left' colspan='2'>Age</th></tr>\n"); | 185 | "<th class='left' colspan='2'>Age</th></tr>\n"); |
186 | 186 | ||
187 | list.refs = NULL; | 187 | list.refs = NULL; |
188 | list.alloc = list.count = 0; | 188 | list.alloc = list.count = 0; |
189 | for_each_branch_ref(cgit_refs_cb, &list); | 189 | for_each_branch_ref(cgit_refs_cb, &list); |
190 | if (ctx.repo->enable_remote_branches) | ||
191 | for_each_remote_ref(cgit_refs_cb, &list); | ||
190 | 192 | ||
191 | if (maxcount == 0 || maxcount > list.count) | 193 | if (maxcount == 0 || maxcount > list.count) |
192 | maxcount = list.count; | 194 | maxcount = list.count; |
193 | 195 | ||
194 | if (maxcount < list.count) { | 196 | if (maxcount < list.count) { |
195 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); | 197 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); |
196 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); | 198 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); |
197 | } | 199 | } |
198 | 200 | ||
199 | for(i=0; i<maxcount; i++) | 201 | for(i=0; i<maxcount; i++) |
200 | print_branch(list.refs[i]); | 202 | print_branch(list.refs[i]); |
201 | 203 | ||
202 | if (maxcount < list.count) | 204 | if (maxcount < list.count) |
203 | print_refs_link("heads"); | 205 | print_refs_link("heads"); |
204 | } | 206 | } |
205 | 207 | ||
206 | void cgit_print_tags(int maxcount) | 208 | void cgit_print_tags(int maxcount) |
207 | { | 209 | { |
208 | struct reflist list; | 210 | struct reflist list; |
209 | int i; | 211 | int i; |
210 | 212 | ||
211 | header = 0; | 213 | header = 0; |
212 | list.refs = NULL; | 214 | list.refs = NULL; |
213 | list.alloc = list.count = 0; | 215 | list.alloc = list.count = 0; |
214 | for_each_tag_ref(cgit_refs_cb, &list); | 216 | for_each_tag_ref(cgit_refs_cb, &list); |
215 | if (list.count == 0) | 217 | if (list.count == 0) |
216 | return; | 218 | return; |
217 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); | 219 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); |
218 | if (!maxcount) | 220 | if (!maxcount) |
219 | maxcount = list.count; | 221 | maxcount = list.count; |
220 | else if (maxcount > list.count) | 222 | else if (maxcount > list.count) |
221 | maxcount = list.count; | 223 | maxcount = list.count; |
222 | print_tag_header(); | 224 | print_tag_header(); |
223 | for(i=0; i<maxcount; i++) | 225 | for(i=0; i<maxcount; i++) |
224 | print_tag(list.refs[i]); | 226 | print_tag(list.refs[i]); |
225 | 227 | ||
226 | if (maxcount < list.count) | 228 | if (maxcount < list.count) |
227 | print_refs_link("tags"); | 229 | print_refs_link("tags"); |
228 | } | 230 | } |
229 | 231 | ||
230 | void cgit_print_refs() | 232 | void cgit_print_refs() |
231 | { | 233 | { |
232 | 234 | ||
233 | html("<table class='list nowrap'>"); | 235 | html("<table class='list nowrap'>"); |
234 | 236 | ||
235 | if (ctx.qry.path && !strncmp(ctx.qry.path, "heads", 5)) | 237 | if (ctx.qry.path && !strncmp(ctx.qry.path, "heads", 5)) |
236 | cgit_print_branches(0); | 238 | cgit_print_branches(0); |
237 | else if (ctx.qry.path && !strncmp(ctx.qry.path, "tags", 4)) | 239 | else if (ctx.qry.path && !strncmp(ctx.qry.path, "tags", 4)) |
238 | cgit_print_tags(0); | 240 | cgit_print_tags(0); |
239 | else { | 241 | else { |
240 | cgit_print_branches(0); | 242 | cgit_print_branches(0); |
241 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 243 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
242 | cgit_print_tags(0); | 244 | cgit_print_tags(0); |
243 | } | 245 | } |
244 | html("</table>"); | 246 | html("</table>"); |
245 | } | 247 | } |