author | Lars Hjemli <hjemli@gmail.com> | 2009-12-12 11:09:47 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-12-12 11:09:47 (UTC) |
commit | 547a64fbd65de293c290f4e18bbeae958d54aaa7 (patch) (unidiff) | |
tree | e35d8ae4e9408cd552e539c5af08d4bd6fdd1e8f /ui-tree.c | |
parent | 0642435fed6793a0d038e1e5097a91293ee89a05 (diff) | |
parent | c86e206a9773f97dc6de6bbf45712bb304de3653 (diff) | |
download | cgit-547a64fbd65de293c290f4e18bbeae958d54aaa7.zip cgit-547a64fbd65de293c290f4e18bbeae958d54aaa7.tar.gz cgit-547a64fbd65de293c290f4e18bbeae958d54aaa7.tar.bz2 |
Merge branch 'stable'
-rw-r--r-- | ui-tree.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -225,67 +225,67 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen, | |||
225 | static char buffer[PATH_MAX]; | 225 | static char buffer[PATH_MAX]; |
226 | char *url; | 226 | char *url; |
227 | 227 | ||
228 | if (state == 0) { | 228 | if (state == 0) { |
229 | memcpy(buffer, base, baselen); | 229 | memcpy(buffer, base, baselen); |
230 | strcpy(buffer+baselen, pathname); | 230 | strcpy(buffer+baselen, pathname); |
231 | url = cgit_pageurl(ctx.qry.repo, "tree", | 231 | url = cgit_pageurl(ctx.qry.repo, "tree", |
232 | fmt("h=%s&path=%s", curr_rev, buffer)); | 232 | fmt("h=%s&path=%s", curr_rev, buffer)); |
233 | html("/"); | 233 | html("/"); |
234 | cgit_tree_link(xstrdup(pathname), NULL, NULL, ctx.qry.head, | 234 | cgit_tree_link(xstrdup(pathname), NULL, NULL, ctx.qry.head, |
235 | curr_rev, buffer); | 235 | curr_rev, buffer); |
236 | 236 | ||
237 | if (strcmp(match_path, buffer)) | 237 | if (strcmp(match_path, buffer)) |
238 | return READ_TREE_RECURSIVE; | 238 | return READ_TREE_RECURSIVE; |
239 | 239 | ||
240 | if (S_ISDIR(mode)) { | 240 | if (S_ISDIR(mode)) { |
241 | state = 1; | 241 | state = 1; |
242 | ls_head(); | 242 | ls_head(); |
243 | return READ_TREE_RECURSIVE; | 243 | return READ_TREE_RECURSIVE; |
244 | } else { | 244 | } else { |
245 | print_object(sha1, buffer, pathname); | 245 | print_object(sha1, buffer, pathname); |
246 | return 0; | 246 | return 0; |
247 | } | 247 | } |
248 | } | 248 | } |
249 | ls_item(sha1, base, baselen, pathname, mode, stage, NULL); | 249 | ls_item(sha1, base, baselen, pathname, mode, stage, NULL); |
250 | return 0; | 250 | return 0; |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | /* | 254 | /* |
255 | * Show a tree or a blob | 255 | * Show a tree or a blob |
256 | * rev: the commit pointing at the root tree object | 256 | * rev: the commit pointing at the root tree object |
257 | * path: path to tree or blob | 257 | * path: path to tree or blob |
258 | */ | 258 | */ |
259 | void cgit_print_tree(const char *rev, char *path) | 259 | void cgit_print_tree(const char *rev, char *path) |
260 | { | 260 | { |
261 | unsigned char sha1[20]; | 261 | unsigned char sha1[20]; |
262 | struct commit *commit; | 262 | struct commit *commit; |
263 | const char *paths[] = {path, NULL}; | 263 | const char *paths[] = {path, NULL}; |
264 | 264 | ||
265 | if (!rev) | 265 | if (!rev) |
266 | rev = ctx.qry.head; | 266 | rev = ctx.qry.head; |
267 | 267 | ||
268 | curr_rev = xstrdup(rev); | 268 | curr_rev = xstrdup(rev); |
269 | if (get_sha1(rev, sha1)) { | 269 | if (get_sha1(rev, sha1)) { |
270 | cgit_print_error(fmt("Invalid revision name: %s", rev)); | 270 | cgit_print_error(fmt("Invalid revision name: %s", rev)); |
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | commit = lookup_commit_reference(sha1); | 273 | commit = lookup_commit_reference(sha1); |
274 | if (!commit || parse_commit(commit)) { | 274 | if (!commit || parse_commit(commit)) { |
275 | cgit_print_error(fmt("Invalid commit reference: %s", rev)); | 275 | cgit_print_error(fmt("Invalid commit reference: %s", rev)); |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | 278 | ||
279 | html("path: <a href='"); | 279 | html("path: <a href='"); |
280 | html_attr(cgit_pageurl(ctx.qry.repo, "tree", fmt("h=%s", rev))); | 280 | html_attr(cgit_pageurl(ctx.qry.repo, "tree", fmt("h=%s", rev))); |
281 | html("'>root</a>"); | 281 | html("'>root</a>"); |
282 | 282 | ||
283 | if (path == NULL) { | 283 | if (path == NULL) { |
284 | ls_tree(commit->tree->object.sha1, NULL); | 284 | ls_tree(commit->tree->object.sha1, NULL); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | 287 | ||
288 | match_path = path; | 288 | match_path = path; |
289 | read_tree_recursive(commit->tree, NULL, 0, 0, paths, walk_tree, NULL); | 289 | read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL); |
290 | ls_tail(); | 290 | ls_tail(); |
291 | } | 291 | } |