author | Lars Hjemli <hjemli@gmail.com> | 2008-02-16 12:56:09 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-02-16 12:56:09 (UTC) |
commit | d1f3bbe9d22029f45a77bb938c176ccc0c827d46 (patch) (unidiff) | |
tree | 3f1741c012763cbc5485f31377abdd9241fbac6b /cgit.c | |
parent | b228d4ff82a65fdcd4a7364759fe36a0bdda5978 (diff) | |
download | cgit-d1f3bbe9d22029f45a77bb938c176ccc0c827d46.zip cgit-d1f3bbe9d22029f45a77bb938c176ccc0c827d46.tar.gz cgit-d1f3bbe9d22029f45a77bb938c176ccc0c827d46.tar.bz2 |
Move cgit_repo into cgit_context
This removes the global variable which is used to keep track of the
currently selected repository, and adds a new variable in the cgit_context
structure.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -12,3 +12,3 @@ static int cgit_prepare_cache(struct cacheitem *item) | |||
12 | { | 12 | { |
13 | if (!cgit_repo && ctx.qry.repo) { | 13 | if (!ctx.repo && ctx.qry.repo) { |
14 | char *title = fmt("%s - %s", ctx.cfg.root_title, "Bad request"); | 14 | char *title = fmt("%s - %s", ctx.cfg.root_title, "Bad request"); |
@@ -21,3 +21,3 @@ static int cgit_prepare_cache(struct cacheitem *item) | |||
21 | 21 | ||
22 | if (!cgit_repo) { | 22 | if (!ctx.repo) { |
23 | item->name = xstrdup(fmt("%s/index.html", ctx.cfg.cache_root)); | 23 | item->name = xstrdup(fmt("%s/index.html", ctx.cfg.cache_root)); |
@@ -29,3 +29,3 @@ static int cgit_prepare_cache(struct cacheitem *item) | |||
29 | item->name = xstrdup(fmt("%s/%s/index.%s.html", ctx.cfg.cache_root, | 29 | item->name = xstrdup(fmt("%s/%s/index.%s.html", ctx.cfg.cache_root, |
30 | cache_safe_filename(cgit_repo->url), | 30 | cache_safe_filename(ctx.repo->url), |
31 | cache_safe_filename(ctx.qry.raw))); | 31 | cache_safe_filename(ctx.qry.raw))); |
@@ -34,3 +34,3 @@ static int cgit_prepare_cache(struct cacheitem *item) | |||
34 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", ctx.cfg.cache_root, | 34 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", ctx.cfg.cache_root, |
35 | cache_safe_filename(cgit_repo->url), | 35 | cache_safe_filename(ctx.repo->url), |
36 | ctx.qry.page, | 36 | ctx.qry.page, |
@@ -66,3 +66,3 @@ int find_current_ref(const char *refname, const unsigned char *sha1, | |||
66 | 66 | ||
67 | char *find_default_branch(struct repoinfo *repo) | 67 | char *find_default_branch(struct cgit_repo *repo) |
68 | { | 68 | { |
@@ -86,3 +86,3 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
86 | 86 | ||
87 | if (chdir(cgit_repo->path)) { | 87 | if (chdir(ctx.repo->path)) { |
88 | title = fmt("%s - %s", ctx.cfg.root_title, "Bad request"); | 88 | title = fmt("%s - %s", ctx.cfg.root_title, "Bad request"); |
@@ -96,9 +96,9 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
96 | 96 | ||
97 | title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); | 97 | title = fmt("%s - %s", ctx.repo->name, ctx.repo->desc); |
98 | show_search = 0; | 98 | show_search = 0; |
99 | setenv("GIT_DIR", cgit_repo->path, 1); | 99 | setenv("GIT_DIR", ctx.repo->path, 1); |
100 | 100 | ||
101 | if (!ctx.qry.head) { | 101 | if (!ctx.qry.head) { |
102 | ctx.qry.head = xstrdup(find_default_branch(cgit_repo)); | 102 | ctx.qry.head = xstrdup(find_default_branch(ctx.repo)); |
103 | cgit_repo->defbranch = ctx.qry.head; | 103 | ctx.repo->defbranch = ctx.qry.head; |
104 | } | 104 | } |
@@ -115,3 +115,3 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
115 | tmp = xstrdup(ctx.qry.head); | 115 | tmp = xstrdup(ctx.qry.head); |
116 | ctx.qry.head = cgit_repo->defbranch; | 116 | ctx.qry.head = ctx.repo->defbranch; |
117 | cgit_print_docstart(title, item); | 117 | cgit_print_docstart(title, item); |
@@ -123,7 +123,7 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
123 | 123 | ||
124 | if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { | 124 | if ((cgit_cmd == CMD_SNAPSHOT) && ctx.repo->snapshots) { |
125 | cgit_print_snapshot(item, ctx.qry.head, ctx.qry.sha1, | 125 | cgit_print_snapshot(item, ctx.qry.head, ctx.qry.sha1, |
126 | cgit_repobasename(cgit_repo->url), | 126 | cgit_repobasename(ctx.repo->url), |
127 | ctx.qry.path, | 127 | ctx.qry.path, |
128 | cgit_repo->snapshots ); | 128 | ctx.repo->snapshots ); |
129 | return; | 129 | return; |
@@ -194,3 +194,3 @@ static void cgit_fill_cache(struct cacheitem *item, int use_cache) | |||
194 | 194 | ||
195 | if (cgit_repo) | 195 | if (ctx.repo) |
196 | cgit_print_repo_page(item); | 196 | cgit_print_repo_page(item); |
@@ -302,3 +302,2 @@ int main(int argc, const char **argv) | |||
302 | cgit_global_config_cb); | 302 | cgit_global_config_cb); |
303 | cgit_repo = NULL; | ||
304 | if (getenv("SCRIPT_NAME")) | 303 | if (getenv("SCRIPT_NAME")) |