|
diff --git a/cgit.c b/cgit.c index a3a04d9..9535abc 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -55,9 +55,9 @@ static void cgit_print_repo_page(struct cacheitem *item) |
55 | cgit_print_summary(); |
55 | cgit_print_summary(); |
56 | } else if (!strcmp(cgit_query_page, "log")) { |
56 | } else if (!strcmp(cgit_query_page, "log")) { |
57 | cgit_print_log(cgit_query_head, cgit_query_ofs, 100, cgit_query_search); |
57 | cgit_print_log(cgit_query_head, cgit_query_ofs, 100, cgit_query_search); |
58 | } else if (!strcmp(cgit_query_page, "tree")) { |
58 | } else if (!strcmp(cgit_query_page, "tree")) { |
59 | cgit_print_tree(cgit_query_sha1); |
59 | cgit_print_tree(cgit_query_sha1, cgit_query_path); |
60 | } else if (!strcmp(cgit_query_page, "commit")) { |
60 | } else if (!strcmp(cgit_query_page, "commit")) { |
61 | cgit_print_commit(cgit_query_sha1); |
61 | cgit_print_commit(cgit_query_sha1); |
62 | } else if (!strcmp(cgit_query_page, "view")) { |
62 | } else if (!strcmp(cgit_query_page, "view")) { |
63 | cgit_print_view(cgit_query_sha1); |
63 | cgit_print_view(cgit_query_sha1); |
|
|
diff --git a/cgit.h b/cgit.h index 3601e49..5e19b11 100644 --- a/ cgit.h+++ b/ cgit.h |
|
@@ -58,8 +58,9 @@ extern char *cgit_query_page; |
58 | extern char *cgit_query_search; |
58 | extern char *cgit_query_search; |
59 | extern char *cgit_query_head; |
59 | extern char *cgit_query_head; |
60 | extern char *cgit_query_sha1; |
60 | extern char *cgit_query_sha1; |
61 | extern char *cgit_query_sha2; |
61 | extern char *cgit_query_sha2; |
| |
62 | extern char *cgit_query_path; |
62 | extern int cgit_query_ofs; |
63 | extern int cgit_query_ofs; |
63 | |
64 | |
64 | extern int htmlfd; |
65 | extern int htmlfd; |
65 | |
66 | |
@@ -107,9 +108,9 @@ extern void cgit_print_pageheader(char *title, int show_search); |
107 | extern void cgit_print_repolist(struct cacheitem *item); |
108 | extern void cgit_print_repolist(struct cacheitem *item); |
108 | extern void cgit_print_summary(); |
109 | extern void cgit_print_summary(); |
109 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep); |
110 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep); |
110 | extern void cgit_print_view(const char *hex); |
111 | extern void cgit_print_view(const char *hex); |
111 | extern void cgit_print_tree(const char *hex); |
112 | extern void cgit_print_tree(const char *hex, char *path); |
112 | extern void cgit_print_commit(const char *hex); |
113 | extern void cgit_print_commit(const char *hex); |
113 | extern void cgit_print_diff(const char *old_hex, const char *new_hex); |
114 | extern void cgit_print_diff(const char *old_hex, const char *new_hex); |
114 | |
115 | |
115 | #endif /* CGIT_H */ |
116 | #endif /* CGIT_H */ |
|
|
diff --git a/shared.c b/shared.c index e4595fa..dd711a8 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -38,8 +38,9 @@ char *cgit_query_page = NULL; |
38 | char *cgit_query_head = NULL; |
38 | char *cgit_query_head = NULL; |
39 | char *cgit_query_search = NULL; |
39 | char *cgit_query_search = NULL; |
40 | char *cgit_query_sha1 = NULL; |
40 | char *cgit_query_sha1 = NULL; |
41 | char *cgit_query_sha2 = NULL; |
41 | char *cgit_query_sha2 = NULL; |
| |
42 | char *cgit_query_path = NULL; |
42 | int cgit_query_ofs = 0; |
43 | int cgit_query_ofs = 0; |
43 | |
44 | |
44 | int htmlfd = 0; |
45 | int htmlfd = 0; |
45 | |
46 | |
@@ -99,8 +100,10 @@ void cgit_querystring_cb(const char *name, const char *value) |
99 | cgit_query_sha2 = xstrdup(value); |
100 | cgit_query_sha2 = xstrdup(value); |
100 | cgit_query_has_sha1 = 1; |
101 | cgit_query_has_sha1 = 1; |
101 | } else if (!strcmp(name, "ofs")) { |
102 | } else if (!strcmp(name, "ofs")) { |
102 | cgit_query_ofs = atoi(value); |
103 | cgit_query_ofs = atoi(value); |
| |
104 | } else if (!strcmp(name, "path")) { |
| |
105 | cgit_query_path = xstrdup(value); |
103 | } |
106 | } |
104 | } |
107 | } |
105 | |
108 | |
106 | void *cgit_free_commitinfo(struct commitinfo *info) |
109 | void *cgit_free_commitinfo(struct commitinfo *info) |
|
|
diff --git a/ui-tree.c b/ui-tree.c index 54dcdbe..ed9f05e 100644 --- a/ ui-tree.c+++ b/ ui-tree.c |
|
@@ -28,13 +28,18 @@ static int print_entry(const unsigned char *sha1, const char *base, |
28 | html("</td><td>"); |
28 | html("</td><td>"); |
29 | if (S_ISDIR(mode)) { |
29 | if (S_ISDIR(mode)) { |
30 | html("<div class='ls-dir'><a href='"); |
30 | html("<div class='ls-dir'><a href='"); |
31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
32 | fmt("id=%s", sha1_to_hex(sha1)))); |
32 | fmt("id=%s&path=%s%s/", |
| |
33 | sha1_to_hex(sha1), |
| |
34 | cgit_query_path ? cgit_query_path : "", |
| |
35 | pathname))); |
33 | } else { |
36 | } else { |
34 | html("<div class='ls-blob'><a href='"); |
37 | html("<div class='ls-blob'><a href='"); |
35 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
38 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
36 | fmt("id=%s", sha1_to_hex(sha1)))); |
39 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), |
| |
40 | cgit_query_path ? cgit_query_path : "", |
| |
41 | pathname))); |
37 | } |
42 | } |
38 | html("'>"); |
43 | html("'>"); |
39 | html_txt(name); |
44 | html_txt(name); |
40 | if (S_ISDIR(mode)) |
45 | if (S_ISDIR(mode)) |
@@ -45,9 +50,9 @@ static int print_entry(const unsigned char *sha1, const char *base, |
45 | free(name); |
50 | free(name); |
46 | return 0; |
51 | return 0; |
47 | } |
52 | } |
48 | |
53 | |
49 | void cgit_print_tree(const char *hex) |
54 | void cgit_print_tree(const char *hex, char *path) |
50 | { |
55 | { |
51 | struct tree *tree; |
56 | struct tree *tree; |
52 | unsigned char sha1[20]; |
57 | unsigned char sha1[20]; |
53 | |
58 | |
@@ -61,8 +66,9 @@ void cgit_print_tree(const char *hex) |
61 | return; |
66 | return; |
62 | } |
67 | } |
63 | |
68 | |
64 | html("<h2>Tree content</h2>\n"); |
69 | html("<h2>Tree content</h2>\n"); |
| |
70 | html_txt(path); |
65 | html("<table class='list'>\n"); |
71 | html("<table class='list'>\n"); |
66 | html("<tr>"); |
72 | html("<tr>"); |
67 | html("<th class='left'>Mode</th>"); |
73 | html("<th class='left'>Mode</th>"); |
68 | html("<th class='left'>Name</th>"); |
74 | html("<th class='left'>Name</th>"); |
|