|
diff --git a/cgit.c b/cgit.c index e8acc03..8a30c3c 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -12,3 +12,3 @@ static int cgit_prepare_cache(struct cacheitem *item) |
12 | { |
12 | { |
13 | if (!cgit_repo && cgit_query_repo) { |
13 | if (!cgit_repo && ctx.qry.repo) { |
14 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
14 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
@@ -16,3 +16,3 @@ static int cgit_prepare_cache(struct cacheitem *item) |
16 | cgit_print_pageheader(title, 0); |
16 | cgit_print_pageheader(title, 0); |
17 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); |
17 | cgit_print_error(fmt("Unknown repo: %s", ctx.qry.repo)); |
18 | cgit_print_docend(); |
18 | cgit_print_docend(); |
@@ -30,3 +30,3 @@ static int cgit_prepare_cache(struct cacheitem *item) |
30 | cache_safe_filename(cgit_repo->url), |
30 | cache_safe_filename(cgit_repo->url), |
31 | cache_safe_filename(cgit_querystring))); |
31 | cache_safe_filename(ctx.qry.raw))); |
32 | item->ttl = cgit_cache_repo_ttl; |
32 | item->ttl = cgit_cache_repo_ttl; |
@@ -35,7 +35,7 @@ static int cgit_prepare_cache(struct cacheitem *item) |
35 | cache_safe_filename(cgit_repo->url), |
35 | cache_safe_filename(cgit_repo->url), |
36 | cgit_query_page, |
36 | ctx.qry.page, |
37 | cache_safe_filename(cgit_querystring))); |
37 | cache_safe_filename(ctx.qry.raw))); |
38 | if (cgit_query_has_symref) |
38 | if (ctx.qry.has_symref) |
39 | item->ttl = cgit_cache_dynamic_ttl; |
39 | item->ttl = cgit_cache_dynamic_ttl; |
40 | else if (cgit_query_has_sha1) |
40 | else if (ctx.qry.has_sha1) |
41 | item->ttl = cgit_cache_static_ttl; |
41 | item->ttl = cgit_cache_static_ttl; |
@@ -100,8 +100,8 @@ static void cgit_print_repo_page(struct cacheitem *item) |
100 | |
100 | |
101 | if (!cgit_query_head) { |
101 | if (!ctx.qry.head) { |
102 | cgit_query_head = xstrdup(find_default_branch(cgit_repo)); |
102 | ctx.qry.head = xstrdup(find_default_branch(cgit_repo)); |
103 | cgit_repo->defbranch = cgit_query_head; |
103 | cgit_repo->defbranch = ctx.qry.head; |
104 | } |
104 | } |
105 | |
105 | |
106 | if (!cgit_query_head) { |
106 | if (!ctx.qry.head) { |
107 | cgit_print_docstart(title, item); |
107 | cgit_print_docstart(title, item); |
@@ -113,5 +113,5 @@ static void cgit_print_repo_page(struct cacheitem *item) |
113 | |
113 | |
114 | if (get_sha1(cgit_query_head, sha1)) { |
114 | if (get_sha1(ctx.qry.head, sha1)) { |
115 | tmp = xstrdup(cgit_query_head); |
115 | tmp = xstrdup(ctx.qry.head); |
116 | cgit_query_head = cgit_repo->defbranch; |
116 | ctx.qry.head = cgit_repo->defbranch; |
117 | cgit_print_docstart(title, item); |
117 | cgit_print_docstart(title, item); |
@@ -124,5 +124,5 @@ static void cgit_print_repo_page(struct cacheitem *item) |
124 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { |
124 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { |
125 | cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, |
125 | cgit_print_snapshot(item, ctx.qry.head, ctx.qry.sha1, |
126 | cgit_repobasename(cgit_repo->url), |
126 | cgit_repobasename(cgit_repo->url), |
127 | cgit_query_path, |
127 | ctx.qry.path, |
128 | cgit_repo->snapshots ); |
128 | cgit_repo->snapshots ); |
@@ -132,3 +132,3 @@ static void cgit_print_repo_page(struct cacheitem *item) |
132 | if (cgit_cmd == CMD_PATCH) { |
132 | if (cgit_cmd == CMD_PATCH) { |
133 | cgit_print_patch(cgit_query_sha1, item); |
133 | cgit_print_patch(ctx.qry.sha1, item); |
134 | return; |
134 | return; |
@@ -137,3 +137,3 @@ static void cgit_print_repo_page(struct cacheitem *item) |
137 | if (cgit_cmd == CMD_BLOB) { |
137 | if (cgit_cmd == CMD_BLOB) { |
138 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
138 | cgit_print_blob(item, ctx.qry.sha1, ctx.qry.path); |
139 | return; |
139 | return; |
@@ -150,3 +150,3 @@ static void cgit_print_repo_page(struct cacheitem *item) |
150 | |
150 | |
151 | cgit_print_pageheader(cgit_query_page, show_search); |
151 | cgit_print_pageheader(ctx.qry.page, show_search); |
152 | |
152 | |
@@ -154,11 +154,11 @@ static void cgit_print_repo_page(struct cacheitem *item) |
154 | case CMD_LOG: |
154 | case CMD_LOG: |
155 | cgit_print_log(cgit_query_sha1, cgit_query_ofs, |
155 | cgit_print_log(ctx.qry.sha1, ctx.qry.ofs, |
156 | cgit_max_commit_count, cgit_query_grep, cgit_query_search, |
156 | cgit_max_commit_count, ctx.qry.grep, ctx.qry.search, |
157 | cgit_query_path, 1); |
157 | ctx.qry.path, 1); |
158 | break; |
158 | break; |
159 | case CMD_TREE: |
159 | case CMD_TREE: |
160 | cgit_print_tree(cgit_query_sha1, cgit_query_path); |
160 | cgit_print_tree(ctx.qry.sha1, ctx.qry.path); |
161 | break; |
161 | break; |
162 | case CMD_COMMIT: |
162 | case CMD_COMMIT: |
163 | cgit_print_commit(cgit_query_sha1); |
163 | cgit_print_commit(ctx.qry.sha1); |
164 | break; |
164 | break; |
@@ -168,6 +168,6 @@ static void cgit_print_repo_page(struct cacheitem *item) |
168 | case CMD_TAG: |
168 | case CMD_TAG: |
169 | cgit_print_tag(cgit_query_sha1); |
169 | cgit_print_tag(ctx.qry.sha1); |
170 | break; |
170 | break; |
171 | case CMD_DIFF: |
171 | case CMD_DIFF: |
172 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); |
172 | cgit_print_diff(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path); |
173 | break; |
173 | break; |
@@ -266,20 +266,20 @@ static void cgit_parse_args(int argc, const char **argv) |
266 | if (!strncmp(argv[i], "--query=", 8)) { |
266 | if (!strncmp(argv[i], "--query=", 8)) { |
267 | cgit_querystring = xstrdup(argv[i]+8); |
267 | ctx.qry.raw = xstrdup(argv[i]+8); |
268 | } |
268 | } |
269 | if (!strncmp(argv[i], "--repo=", 7)) { |
269 | if (!strncmp(argv[i], "--repo=", 7)) { |
270 | cgit_query_repo = xstrdup(argv[i]+7); |
270 | ctx.qry.repo = xstrdup(argv[i]+7); |
271 | } |
271 | } |
272 | if (!strncmp(argv[i], "--page=", 7)) { |
272 | if (!strncmp(argv[i], "--page=", 7)) { |
273 | cgit_query_page = xstrdup(argv[i]+7); |
273 | ctx.qry.page = xstrdup(argv[i]+7); |
274 | } |
274 | } |
275 | if (!strncmp(argv[i], "--head=", 7)) { |
275 | if (!strncmp(argv[i], "--head=", 7)) { |
276 | cgit_query_head = xstrdup(argv[i]+7); |
276 | ctx.qry.head = xstrdup(argv[i]+7); |
277 | cgit_query_has_symref = 1; |
277 | ctx.qry.has_symref = 1; |
278 | } |
278 | } |
279 | if (!strncmp(argv[i], "--sha1=", 7)) { |
279 | if (!strncmp(argv[i], "--sha1=", 7)) { |
280 | cgit_query_sha1 = xstrdup(argv[i]+7); |
280 | ctx.qry.sha1 = xstrdup(argv[i]+7); |
281 | cgit_query_has_sha1 = 1; |
281 | ctx.qry.has_sha1 = 1; |
282 | } |
282 | } |
283 | if (!strncmp(argv[i], "--ofs=", 6)) { |
283 | if (!strncmp(argv[i], "--ofs=", 6)) { |
284 | cgit_query_ofs = atoi(argv[i]+6); |
284 | ctx.qry.ofs = atoi(argv[i]+6); |
285 | } |
285 | } |
@@ -305,5 +305,5 @@ int main(int argc, const char **argv) |
305 | if (getenv("QUERY_STRING")) |
305 | if (getenv("QUERY_STRING")) |
306 | cgit_querystring = xstrdup(getenv("QUERY_STRING")); |
306 | ctx.qry.raw = xstrdup(getenv("QUERY_STRING")); |
307 | cgit_parse_args(argc, argv); |
307 | cgit_parse_args(argc, argv); |
308 | cgit_parse_query(cgit_querystring, cgit_querystring_cb); |
308 | cgit_parse_query(ctx.qry.raw, cgit_querystring_cb); |
309 | if (!cgit_prepare_cache(&item)) |
309 | if (!cgit_prepare_cache(&item)) |
|