-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 3 | ||||
-rw-r--r-- | shared.c | 3 | ||||
-rw-r--r-- | ui-tree.c | 12 |
4 files changed, 15 insertions, 5 deletions
@@ -55,9 +55,9 @@ static void cgit_print_repo_page(struct cacheitem *item) cgit_print_summary(); } else if (!strcmp(cgit_query_page, "log")) { cgit_print_log(cgit_query_head, cgit_query_ofs, 100, cgit_query_search); } else if (!strcmp(cgit_query_page, "tree")) { - cgit_print_tree(cgit_query_sha1); + cgit_print_tree(cgit_query_sha1, cgit_query_path); } else if (!strcmp(cgit_query_page, "commit")) { cgit_print_commit(cgit_query_sha1); } else if (!strcmp(cgit_query_page, "view")) { cgit_print_view(cgit_query_sha1); @@ -58,8 +58,9 @@ extern char *cgit_query_page; extern char *cgit_query_search; extern char *cgit_query_head; extern char *cgit_query_sha1; extern char *cgit_query_sha2; +extern char *cgit_query_path; extern int cgit_query_ofs; extern int htmlfd; @@ -107,9 +108,9 @@ extern void cgit_print_pageheader(char *title, int show_search); extern void cgit_print_repolist(struct cacheitem *item); extern void cgit_print_summary(); extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep); extern void cgit_print_view(const char *hex); -extern void cgit_print_tree(const char *hex); +extern void cgit_print_tree(const char *hex, char *path); extern void cgit_print_commit(const char *hex); extern void cgit_print_diff(const char *old_hex, const char *new_hex); #endif /* CGIT_H */ @@ -38,8 +38,9 @@ char *cgit_query_page = NULL; char *cgit_query_head = NULL; char *cgit_query_search = NULL; char *cgit_query_sha1 = NULL; char *cgit_query_sha2 = NULL; +char *cgit_query_path = NULL; int cgit_query_ofs = 0; int htmlfd = 0; @@ -99,8 +100,10 @@ void cgit_querystring_cb(const char *name, const char *value) cgit_query_sha2 = xstrdup(value); cgit_query_has_sha1 = 1; } else if (!strcmp(name, "ofs")) { cgit_query_ofs = atoi(value); + } else if (!strcmp(name, "path")) { + cgit_query_path = xstrdup(value); } } void *cgit_free_commitinfo(struct commitinfo *info) @@ -28,13 +28,18 @@ static int print_entry(const unsigned char *sha1, const char *base, html("</td><td>"); if (S_ISDIR(mode)) { html("<div class='ls-dir'><a href='"); html_attr(cgit_pageurl(cgit_query_repo, "tree", - fmt("id=%s", sha1_to_hex(sha1)))); + fmt("id=%s&path=%s%s/", + sha1_to_hex(sha1), + cgit_query_path ? cgit_query_path : "", + pathname))); } else { html("<div class='ls-blob'><a href='"); html_attr(cgit_pageurl(cgit_query_repo, "view", - fmt("id=%s", sha1_to_hex(sha1)))); + fmt("id=%s&path=%s%s", sha1_to_hex(sha1), + cgit_query_path ? cgit_query_path : "", + pathname))); } html("'>"); html_txt(name); if (S_ISDIR(mode)) @@ -45,9 +50,9 @@ static int print_entry(const unsigned char *sha1, const char *base, free(name); return 0; } -void cgit_print_tree(const char *hex) +void cgit_print_tree(const char *hex, char *path) { struct tree *tree; unsigned char sha1[20]; @@ -61,8 +66,9 @@ void cgit_print_tree(const char *hex) return; } html("<h2>Tree content</h2>\n"); + html_txt(path); html("<table class='list'>\n"); html("<tr>"); html("<th class='left'>Mode</th>"); html("<th class='left'>Name</th>"); |