|
diff --git a/cgit.c b/cgit.c index 3c11ff0..b282a67 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -36,64 +36,67 @@ static int cgit_prepare_cache(struct cacheitem *item) |
36 | if (!cgit_repo) { |
36 | if (!cgit_repo) { |
37 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
37 | char *title = fmt("%s - %s", cgit_root_title, "Bad request"); |
38 | cgit_print_docstart(title, item); |
38 | cgit_print_docstart(title, item); |
39 | cgit_print_pageheader(title, 0); |
39 | cgit_print_pageheader(title, 0); |
40 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); |
40 | cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); |
41 | cgit_print_docend(); |
41 | cgit_print_docend(); |
42 | return 0; |
42 | return 0; |
43 | } |
43 | } |
44 | |
44 | |
45 | if (!cgit_query_page) { |
45 | if (!cgit_query_page) { |
46 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, |
46 | item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, |
47 | cgit_repo->url)); |
47 | cgit_repo->url)); |
48 | item->ttl = cgit_cache_repo_ttl; |
48 | item->ttl = cgit_cache_repo_ttl; |
49 | } else { |
49 | } else { |
50 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
50 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
51 | cgit_repo->url, cgit_query_page, |
51 | cgit_repo->url, cgit_query_page, |
52 | cache_safe_filename(cgit_querystring))); |
52 | cache_safe_filename(cgit_querystring))); |
53 | if (cgit_query_has_symref) |
53 | if (cgit_query_has_symref) |
54 | item->ttl = cgit_cache_dynamic_ttl; |
54 | item->ttl = cgit_cache_dynamic_ttl; |
55 | else if (cgit_query_has_sha1) |
55 | else if (cgit_query_has_sha1) |
56 | item->ttl = cgit_cache_static_ttl; |
56 | item->ttl = cgit_cache_static_ttl; |
57 | else |
57 | else |
58 | item->ttl = cgit_cache_repo_ttl; |
58 | item->ttl = cgit_cache_repo_ttl; |
59 | } |
59 | } |
60 | return 1; |
60 | return 1; |
61 | } |
61 | } |
62 | |
62 | |
63 | static void cgit_print_repo_page(struct cacheitem *item) |
63 | static void cgit_print_repo_page(struct cacheitem *item) |
64 | { |
64 | { |
65 | char *title; |
65 | char *title; |
66 | int show_search; |
66 | int show_search; |
67 | |
67 | |
| |
68 | if (!cgit_query_head) |
| |
69 | cgit_query_head = cgit_repo->defbranch; |
| |
70 | |
68 | if (chdir(cgit_repo->path)) { |
71 | if (chdir(cgit_repo->path)) { |
69 | title = fmt("%s - %s", cgit_root_title, "Bad request"); |
72 | title = fmt("%s - %s", cgit_root_title, "Bad request"); |
70 | cgit_print_docstart(title, item); |
73 | cgit_print_docstart(title, item); |
71 | cgit_print_pageheader(title, 0); |
74 | cgit_print_pageheader(title, 0); |
72 | cgit_print_error(fmt("Unable to scan repository: %s", |
75 | cgit_print_error(fmt("Unable to scan repository: %s", |
73 | strerror(errno))); |
76 | strerror(errno))); |
74 | cgit_print_docend(); |
77 | cgit_print_docend(); |
75 | return; |
78 | return; |
76 | } |
79 | } |
77 | |
80 | |
78 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); |
81 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); |
79 | show_search = 0; |
82 | show_search = 0; |
80 | setenv("GIT_DIR", cgit_repo->path, 1); |
83 | setenv("GIT_DIR", cgit_repo->path, 1); |
81 | |
84 | |
82 | if (cgit_query_page) { |
85 | if (cgit_query_page) { |
83 | if (cgit_repo->snapshots && !strcmp(cgit_query_page, "snapshot")) { |
86 | if (cgit_repo->snapshots && !strcmp(cgit_query_page, "snapshot")) { |
84 | cgit_print_snapshot(item, cgit_query_sha1, "zip", |
87 | cgit_print_snapshot(item, cgit_query_sha1, "zip", |
85 | cgit_repo->url, cgit_query_name); |
88 | cgit_repo->url, cgit_query_name); |
86 | return; |
89 | return; |
87 | } |
90 | } |
88 | if (!strcmp(cgit_query_page, "blob")) { |
91 | if (!strcmp(cgit_query_page, "blob")) { |
89 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
92 | cgit_print_blob(item, cgit_query_sha1, cgit_query_path); |
90 | return; |
93 | return; |
91 | } |
94 | } |
92 | } |
95 | } |
93 | |
96 | |
94 | if (cgit_query_page && !strcmp(cgit_query_page, "log")) |
97 | if (cgit_query_page && !strcmp(cgit_query_page, "log")) |
95 | show_search = 1; |
98 | show_search = 1; |
96 | |
99 | |
97 | cgit_print_docstart(title, item); |
100 | cgit_print_docstart(title, item); |
98 | |
101 | |
99 | |
102 | |
|