summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-02-16 12:56:09 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-02-16 12:56:09 (UTC)
commitd1f3bbe9d22029f45a77bb938c176ccc0c827d46 (patch) (unidiff)
tree3f1741c012763cbc5485f31377abdd9241fbac6b
parentb228d4ff82a65fdcd4a7364759fe36a0bdda5978 (diff)
downloadcgit-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>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cache.c6
-rw-r--r--cgit.c31
-rw-r--r--cgit.h12
-rw-r--r--parsing.c16
-rw-r--r--shared.c61
-rw-r--r--ui-commit.c4
-rw-r--r--ui-log.c10
-rw-r--r--ui-repolist.c30
-rw-r--r--ui-shared.c28
-rw-r--r--ui-summary.c4
-rw-r--r--ui-tree.c2
11 files changed, 101 insertions, 103 deletions
diff --git a/cache.c b/cache.c
index 2ed0d6f..7860fc7 100644
--- a/cache.c
+++ b/cache.c
@@ -48,18 +48,18 @@ int cache_create_dirs()
48 if (mkdir(path, S_IRWXU) && errno!=EEXIST) 48 if (mkdir(path, S_IRWXU) && errno!=EEXIST)
49 return 0; 49 return 0;
50 50
51 if (!cgit_repo) 51 if (!ctx.repo)
52 return 0; 52 return 0;
53 53
54 path = fmt("%s/%s", ctx.cfg.cache_root, 54 path = fmt("%s/%s", ctx.cfg.cache_root,
55 cache_safe_filename(cgit_repo->url)); 55 cache_safe_filename(ctx.repo->url));
56 56
57 if (mkdir(path, S_IRWXU) && errno!=EEXIST) 57 if (mkdir(path, S_IRWXU) && errno!=EEXIST)
58 return 0; 58 return 0;
59 59
60 if (ctx.qry.page) { 60 if (ctx.qry.page) {
61 path = fmt("%s/%s/%s", ctx.cfg.cache_root, 61 path = fmt("%s/%s/%s", ctx.cfg.cache_root,
62 cache_safe_filename(cgit_repo->url), 62 cache_safe_filename(ctx.repo->url),
63 ctx.qry.page); 63 ctx.qry.page);
64 if (mkdir(path, S_IRWXU) && errno!=EEXIST) 64 if (mkdir(path, S_IRWXU) && errno!=EEXIST)
65 return 0; 65 return 0;
diff --git a/cgit.c b/cgit.c
index f0907a1..b270fdc 100644
--- a/cgit.c
+++ b/cgit.c
@@ -10,7 +10,7 @@
10 10
11static int cgit_prepare_cache(struct cacheitem *item) 11static 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");
15 cgit_print_docstart(title, item); 15 cgit_print_docstart(title, item);
16 cgit_print_pageheader(title, 0); 16 cgit_print_pageheader(title, 0);
@@ -19,7 +19,7 @@ static int cgit_prepare_cache(struct cacheitem *item)
19 return 0; 19 return 0;
20 } 20 }
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));
24 item->ttl = ctx.cfg.cache_root_ttl; 24 item->ttl = ctx.cfg.cache_root_ttl;
25 return 1; 25 return 1;
@@ -27,12 +27,12 @@ static int cgit_prepare_cache(struct cacheitem *item)
27 27
28 if (!cgit_cmd) { 28 if (!cgit_cmd) {
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)));
32 item->ttl = ctx.cfg.cache_repo_ttl; 32 item->ttl = ctx.cfg.cache_repo_ttl;
33 } else { 33 } else {
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,
37 cache_safe_filename(ctx.qry.raw))); 37 cache_safe_filename(ctx.qry.raw)));
38 if (ctx.qry.has_symref) 38 if (ctx.qry.has_symref)
@@ -64,7 +64,7 @@ int find_current_ref(const char *refname, const unsigned char *sha1,
64 return info->match; 64 return info->match;
65} 65}
66 66
67char *find_default_branch(struct repoinfo *repo) 67char *find_default_branch(struct cgit_repo *repo)
68{ 68{
69 struct refmatch info; 69 struct refmatch info;
70 70
@@ -84,7 +84,7 @@ static void cgit_print_repo_page(struct cacheitem *item)
84 int show_search; 84 int show_search;
85 unsigned char sha1[20]; 85 unsigned char sha1[20];
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");
89 cgit_print_docstart(title, item); 89 cgit_print_docstart(title, item);
90 cgit_print_pageheader(title, 0); 90 cgit_print_pageheader(title, 0);
@@ -94,13 +94,13 @@ static void cgit_print_repo_page(struct cacheitem *item)
94 return; 94 return;
95 } 95 }
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 }
105 105
106 if (!ctx.qry.head) { 106 if (!ctx.qry.head) {
@@ -113,7 +113,7 @@ static void cgit_print_repo_page(struct cacheitem *item)
113 113
114 if (get_sha1(ctx.qry.head, sha1)) { 114 if (get_sha1(ctx.qry.head, sha1)) {
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);
118 cgit_print_pageheader(title, 0); 118 cgit_print_pageheader(title, 0);
119 cgit_print_error(fmt("Invalid branch: %s", tmp)); 119 cgit_print_error(fmt("Invalid branch: %s", tmp));
@@ -121,11 +121,11 @@ static void cgit_print_repo_page(struct cacheitem *item)
121 return; 121 return;
122 } 122 }
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;
130 } 130 }
131 131
@@ -192,7 +192,7 @@ static void cgit_fill_cache(struct cacheitem *item, int use_cache)
192 chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); 192 chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)");
193 } 193 }
194 194
195 if (cgit_repo) 195 if (ctx.repo)
196 cgit_print_repo_page(item); 196 cgit_print_repo_page(item);
197 else 197 else
198 cgit_print_repolist(item); 198 cgit_print_repolist(item);
@@ -300,7 +300,6 @@ int main(int argc, const char **argv)
300 300
301 cgit_read_config(cgit_config_env ? cgit_config_env : CGIT_CONFIG, 301 cgit_read_config(cgit_config_env ? cgit_config_env : CGIT_CONFIG,
302 cgit_global_config_cb); 302 cgit_global_config_cb);
303 cgit_repo = NULL;
304 if (getenv("SCRIPT_NAME")) 303 if (getenv("SCRIPT_NAME"))
305 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME")); 304 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
306 if (getenv("QUERY_STRING")) 305 if (getenv("QUERY_STRING"))
diff --git a/cgit.h b/cgit.h
index 0338ebd..598d8c3 100644
--- a/cgit.h
+++ b/cgit.h
@@ -66,7 +66,7 @@ struct cacheitem {
66 int fd; 66 int fd;
67}; 67};
68 68
69struct repoinfo { 69struct cgit_repo {
70 char *url; 70 char *url;
71 char *name; 71 char *name;
72 char *path; 72 char *path;
@@ -82,10 +82,10 @@ struct repoinfo {
82 int enable_log_linecount; 82 int enable_log_linecount;
83}; 83};
84 84
85struct repolist { 85struct cgit_repolist {
86 int length; 86 int length;
87 int count; 87 int count;
88 struct repoinfo *repos; 88 struct cgit_repo *repos;
89}; 89};
90 90
91struct commitinfo { 91struct commitinfo {
@@ -177,12 +177,12 @@ struct cgit_config {
177struct cgit_context { 177struct cgit_context {
178 struct cgit_query qry; 178 struct cgit_query qry;
179 struct cgit_config cfg; 179 struct cgit_config cfg;
180 struct cgit_repo *repo;
180}; 181};
181 182
182extern const char *cgit_version; 183extern const char *cgit_version;
183 184
184extern struct repolist cgit_repolist; 185extern struct cgit_repolist cgit_repolist;
185extern struct repoinfo *cgit_repo;
186extern struct cgit_context ctx; 186extern struct cgit_context ctx;
187extern int cgit_cmd; 187extern int cgit_cmd;
188 188
@@ -190,7 +190,7 @@ extern int htmlfd;
190 190
191extern void cgit_prepare_context(struct cgit_context *ctx); 191extern void cgit_prepare_context(struct cgit_context *ctx);
192extern int cgit_get_cmd_index(const char *cmd); 192extern int cgit_get_cmd_index(const char *cmd);
193extern struct repoinfo *cgit_get_repoinfo(const char *url); 193extern struct cgit_repo *cgit_get_repoinfo(const char *url);
194extern void cgit_global_config_cb(const char *name, const char *value); 194extern void cgit_global_config_cb(const char *name, const char *value);
195extern void cgit_repo_config_cb(const char *name, const char *value); 195extern void cgit_repo_config_cb(const char *name, const char *value);
196extern void cgit_querystring_cb(const char *name, const char *value); 196extern void cgit_querystring_cb(const char *name, const char *value);
diff --git a/parsing.c b/parsing.c
index 8cf56a4..027f06b 100644
--- a/parsing.c
+++ b/parsing.c
@@ -143,27 +143,27 @@ void cgit_parse_url(const char *url)
143{ 143{
144 char *cmd, *p; 144 char *cmd, *p;
145 145
146 cgit_repo = NULL; 146 ctx.repo = NULL;
147 if (!url || url[0] == '\0') 147 if (!url || url[0] == '\0')
148 return; 148 return;
149 149
150 cgit_repo = cgit_get_repoinfo(url); 150 ctx.repo = cgit_get_repoinfo(url);
151 if (cgit_repo) { 151 if (ctx.repo) {
152 ctx.qry.repo = cgit_repo->url; 152 ctx.qry.repo = ctx.repo->url;
153 return; 153 return;
154 } 154 }
155 155
156 cmd = strchr(url, '/'); 156 cmd = strchr(url, '/');
157 while (!cgit_repo && cmd) { 157 while (!ctx.repo && cmd) {
158 cmd[0] = '\0'; 158 cmd[0] = '\0';
159 cgit_repo = cgit_get_repoinfo(url); 159 ctx.repo = cgit_get_repoinfo(url);
160 if (cgit_repo == NULL) { 160 if (ctx.repo == NULL) {
161 cmd[0] = '/'; 161 cmd[0] = '/';
162 cmd = strchr(cmd + 1, '/'); 162 cmd = strchr(cmd + 1, '/');
163 continue; 163 continue;
164 } 164 }
165 165
166 ctx.qry.repo = cgit_repo->url; 166 ctx.qry.repo = ctx.repo->url;
167 p = strchr(cmd + 1, '/'); 167 p = strchr(cmd + 1, '/');
168 if (p) { 168 if (p) {
169 p[0] = '\0'; 169 p[0] = '\0';
diff --git a/shared.c b/shared.c
index 8dd2b00..808e674 100644
--- a/shared.c
+++ b/shared.c
@@ -8,8 +8,7 @@
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11struct repolist cgit_repolist; 11struct cgit_repolist cgit_repolist;
12struct repoinfo *cgit_repo;
13struct cgit_context ctx; 12struct cgit_context ctx;
14int cgit_cmd; 13int cgit_cmd;
15 14
@@ -73,9 +72,9 @@ int chk_non_negative(int result, char *msg)
73 return result; 72 return result;
74} 73}
75 74
76struct repoinfo *add_repo(const char *url) 75struct cgit_repo *add_repo(const char *url)
77{ 76{
78 struct repoinfo *ret; 77 struct cgit_repo *ret;
79 78
80 if (++cgit_repolist.count > cgit_repolist.length) { 79 if (++cgit_repolist.count > cgit_repolist.length) {
81 if (cgit_repolist.length == 0) 80 if (cgit_repolist.length == 0)
@@ -84,7 +83,7 @@ struct repoinfo *add_repo(const char *url)
84 cgit_repolist.length *= 2; 83 cgit_repolist.length *= 2;
85 cgit_repolist.repos = xrealloc(cgit_repolist.repos, 84 cgit_repolist.repos = xrealloc(cgit_repolist.repos,
86 cgit_repolist.length * 85 cgit_repolist.length *
87 sizeof(struct repoinfo)); 86 sizeof(struct cgit_repo));
88 } 87 }
89 88
90 ret = &cgit_repolist.repos[cgit_repolist.count-1]; 89 ret = &cgit_repolist.repos[cgit_repolist.count-1];
@@ -103,10 +102,10 @@ struct repoinfo *add_repo(const char *url)
103 return ret; 102 return ret;
104} 103}
105 104
106struct repoinfo *cgit_get_repoinfo(const char *url) 105struct cgit_repo *cgit_get_repoinfo(const char *url)
107{ 106{
108 int i; 107 int i;
109 struct repoinfo *repo; 108 struct cgit_repo *repo;
110 109
111 for (i=0; i<cgit_repolist.count; i++) { 110 for (i=0; i<cgit_repolist.count; i++) {
112 repo = &cgit_repolist.repos[i]; 111 repo = &cgit_repolist.repos[i];
@@ -179,32 +178,32 @@ void cgit_global_config_cb(const char *name, const char *value)
179 else if (!strcmp(name, "repo.group")) 178 else if (!strcmp(name, "repo.group"))
180 ctx.cfg.repo_group = xstrdup(value); 179 ctx.cfg.repo_group = xstrdup(value);
181 else if (!strcmp(name, "repo.url")) 180 else if (!strcmp(name, "repo.url"))
182 cgit_repo = add_repo(value); 181 ctx.repo = add_repo(value);
183 else if (!strcmp(name, "repo.name")) 182 else if (!strcmp(name, "repo.name"))
184 cgit_repo->name = xstrdup(value); 183 ctx.repo->name = xstrdup(value);
185 else if (cgit_repo && !strcmp(name, "repo.path")) 184 else if (ctx.repo && !strcmp(name, "repo.path"))
186 cgit_repo->path = trim_end(value, '/'); 185 ctx.repo->path = trim_end(value, '/');
187 else if (cgit_repo && !strcmp(name, "repo.clone-url")) 186 else if (ctx.repo && !strcmp(name, "repo.clone-url"))
188 cgit_repo->clone_url = xstrdup(value); 187 ctx.repo->clone_url = xstrdup(value);
189 else if (cgit_repo && !strcmp(name, "repo.desc")) 188 else if (ctx.repo && !strcmp(name, "repo.desc"))
190 cgit_repo->desc = xstrdup(value); 189 ctx.repo->desc = xstrdup(value);
191 else if (cgit_repo && !strcmp(name, "repo.owner")) 190 else if (ctx.repo && !strcmp(name, "repo.owner"))
192 cgit_repo->owner = xstrdup(value); 191 ctx.repo->owner = xstrdup(value);
193 else if (cgit_repo && !strcmp(name, "repo.defbranch")) 192 else if (ctx.repo && !strcmp(name, "repo.defbranch"))
194 cgit_repo->defbranch = xstrdup(value); 193 ctx.repo->defbranch = xstrdup(value);
195 else if (cgit_repo && !strcmp(name, "repo.snapshots")) 194 else if (ctx.repo && !strcmp(name, "repo.snapshots"))
196 cgit_repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ 195 ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
197 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) 196 else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount"))
198 cgit_repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); 197 ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
199 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) 198 else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))
200 cgit_repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); 199 ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
201 else if (cgit_repo && !strcmp(name, "repo.module-link")) 200 else if (ctx.repo && !strcmp(name, "repo.module-link"))
202 cgit_repo->module_link= xstrdup(value); 201 ctx.repo->module_link= xstrdup(value);
203 else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { 202 else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
204 if (*value == '/') 203 if (*value == '/')
205 cgit_repo->readme = xstrdup(value); 204 ctx.repo->readme = xstrdup(value);
206 else 205 else
207 cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); 206 ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
208 } else if (!strcmp(name, "include")) 207 } else if (!strcmp(name, "include"))
209 cgit_read_config(value, cgit_global_config_cb); 208 cgit_read_config(value, cgit_global_config_cb);
210} 209}
@@ -213,7 +212,7 @@ void cgit_querystring_cb(const char *name, const char *value)
213{ 212{
214 if (!strcmp(name,"r")) { 213 if (!strcmp(name,"r")) {
215 ctx.qry.repo = xstrdup(value); 214 ctx.qry.repo = xstrdup(value);
216 cgit_repo = cgit_get_repoinfo(value); 215 ctx.repo = cgit_get_repoinfo(value);
217 } else if (!strcmp(name, "p")) { 216 } else if (!strcmp(name, "p")) {
218 ctx.qry.page = xstrdup(value); 217 ctx.qry.page = xstrdup(value);
219 cgit_cmd = cgit_get_cmd_index(value); 218 cgit_cmd = cgit_get_cmd_index(value);
diff --git a/ui-commit.c b/ui-commit.c
index 3b0919b..25721ca 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -194,10 +194,10 @@ void cgit_print_commit(char *hex)
194 sha1_to_hex(p->item->object.sha1), NULL); 194 sha1_to_hex(p->item->object.sha1), NULL);
195 html(")</td></tr>"); 195 html(")</td></tr>");
196 } 196 }
197 if (cgit_repo->snapshots) { 197 if (ctx.repo->snapshots) {
198 html("<tr><th>download</th><td colspan='2' class='sha1'>"); 198 html("<tr><th>download</th><td colspan='2' class='sha1'>");
199 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, 199 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
200 hex, cgit_repo->snapshots); 200 hex, ctx.repo->snapshots);
201 html("</td></tr>"); 201 html("</td></tr>");
202 } 202 }
203 html("</table>\n"); 203 html("</table>\n");
diff --git a/ui-log.c b/ui-log.c
index a39474b..72e2a4b 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -25,7 +25,7 @@ void count_lines(char *line, int size)
25void inspect_files(struct diff_filepair *pair) 25void inspect_files(struct diff_filepair *pair)
26{ 26{
27 files++; 27 files++;
28 if (cgit_repo->enable_log_linecount) 28 if (ctx.repo->enable_log_linecount)
29 cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); 29 cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines);
30} 30}
31 31
@@ -39,14 +39,14 @@ void print_commit(struct commit *commit)
39 html("</td><td>"); 39 html("</td><td>");
40 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, 40 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
41 sha1_to_hex(commit->object.sha1)); 41 sha1_to_hex(commit->object.sha1));
42 if (cgit_repo->enable_log_filecount) { 42 if (ctx.repo->enable_log_filecount) {
43 files = 0; 43 files = 0;
44 add_lines = 0; 44 add_lines = 0;
45 rem_lines = 0; 45 rem_lines = 0;
46 cgit_diff_commit(commit, inspect_files); 46 cgit_diff_commit(commit, inspect_files);
47 html("</td><td class='right'>"); 47 html("</td><td class='right'>");
48 htmlf("%d", files); 48 htmlf("%d", files);
49 if (cgit_repo->enable_log_linecount) { 49 if (ctx.repo->enable_log_linecount) {
50 html("</td><td class='right'>"); 50 html("</td><td class='right'>");
51 htmlf("-%d/+%d", rem_lines, add_lines); 51 htmlf("-%d/+%d", rem_lines, add_lines);
52 } 52 }
@@ -94,9 +94,9 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
94 html("<tr class='nohover'><th class='left'>Age</th>" 94 html("<tr class='nohover'><th class='left'>Age</th>"
95 "<th class='left'>Message</th>"); 95 "<th class='left'>Message</th>");
96 96
97 if (cgit_repo->enable_log_filecount) { 97 if (ctx.repo->enable_log_filecount) {
98 html("<th class='right'>Files</th>"); 98 html("<th class='right'>Files</th>");
99 if (cgit_repo->enable_log_linecount) 99 if (ctx.repo->enable_log_linecount)
100 html("<th class='right'>Lines</th>"); 100 html("<th class='right'>Lines</th>");
101 } 101 }
102 html("<th class='left'>Author</th></tr>\n"); 102 html("<th class='left'>Author</th></tr>\n");
diff --git a/ui-repolist.c b/ui-repolist.c
index a6cc2cc..5fde174 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -25,7 +25,7 @@ time_t read_agefile(char *path)
25 return 0; 25 return 0;
26} 26}
27 27
28static void print_modtime(struct repoinfo *repo) 28static void print_modtime(struct cgit_repo *repo)
29{ 29{
30 char *path; 30 char *path;
31 struct stat s; 31 struct stat s;
@@ -70,32 +70,32 @@ void cgit_print_repolist(struct cacheitem *item)
70 html("</tr>\n"); 70 html("</tr>\n");
71 71
72 for (i=0; i<cgit_repolist.count; i++) { 72 for (i=0; i<cgit_repolist.count; i++) {
73 cgit_repo = &cgit_repolist.repos[i]; 73 ctx.repo = &cgit_repolist.repos[i];
74 if ((last_group == NULL && cgit_repo->group != NULL) || 74 if ((last_group == NULL && ctx.repo->group != NULL) ||
75 (last_group != NULL && cgit_repo->group == NULL) || 75 (last_group != NULL && ctx.repo->group == NULL) ||
76 (last_group != NULL && cgit_repo->group != NULL && 76 (last_group != NULL && ctx.repo->group != NULL &&
77 strcmp(cgit_repo->group, last_group))) { 77 strcmp(ctx.repo->group, last_group))) {
78 htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", 78 htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>",
79 columns); 79 columns);
80 html_txt(cgit_repo->group); 80 html_txt(ctx.repo->group);
81 html("</td></tr>"); 81 html("</td></tr>");
82 last_group = cgit_repo->group; 82 last_group = ctx.repo->group;
83 } 83 }
84 htmlf("<tr><td class='%s'>", 84 htmlf("<tr><td class='%s'>",
85 cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); 85 ctx.repo->group ? "sublevel-repo" : "toplevel-repo");
86 html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL); 86 html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL);
87 html_txt(cgit_repo->name); 87 html_txt(ctx.repo->name);
88 html_link_close(); 88 html_link_close();
89 html("</td><td>"); 89 html("</td><td>");
90 html_ntxt(ctx.cfg.max_repodesc_len, cgit_repo->desc); 90 html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc);
91 html("</td><td>"); 91 html("</td><td>");
92 html_txt(cgit_repo->owner); 92 html_txt(ctx.repo->owner);
93 html("</td><td>"); 93 html("</td><td>");
94 print_modtime(cgit_repo); 94 print_modtime(ctx.repo);
95 html("</td>"); 95 html("</td>");
96 if (ctx.cfg.enable_index_links) { 96 if (ctx.cfg.enable_index_links) {
97 html("<td>"); 97 html("<td>");
98 html_link_open(cgit_repourl(cgit_repo->url), 98 html_link_open(cgit_repourl(ctx.repo->url),
99 NULL, "button"); 99 NULL, "button");
100 html("summary</a>"); 100 html("summary</a>");
101 cgit_log_link("log", NULL, "button", NULL, NULL, NULL, 101 cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
diff --git a/ui-shared.c b/ui-shared.c
index b96237d..b9f487a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -141,8 +141,8 @@ static char *repolink(char *title, char *class, char *page, char *head,
141 html_attr(ctx.cfg.virtual_root); 141 html_attr(ctx.cfg.virtual_root);
142 if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/') 142 if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/')
143 html("/"); 143 html("/");
144 html_attr(cgit_repo->url); 144 html_attr(ctx.repo->url);
145 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') 145 if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/')
146 html("/"); 146 html("/");
147 if (page) { 147 if (page) {
148 html(page); 148 html(page);
@@ -153,8 +153,8 @@ static char *repolink(char *title, char *class, char *page, char *head,
153 } else { 153 } else {
154 html(ctx.cfg.script_name); 154 html(ctx.cfg.script_name);
155 html("?url="); 155 html("?url=");
156 html_attr(cgit_repo->url); 156 html_attr(ctx.repo->url);
157 if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/') 157 if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/')
158 html("/"); 158 html("/");
159 if (page) { 159 if (page) {
160 html(page); 160 html(page);
@@ -164,7 +164,7 @@ static char *repolink(char *title, char *class, char *page, char *head,
164 } 164 }
165 delim = "&amp;"; 165 delim = "&amp;";
166 } 166 }
167 if (head && strcmp(head, cgit_repo->defbranch)) { 167 if (head && strcmp(head, ctx.repo->defbranch)) {
168 html(delim); 168 html(delim);
169 html("h="); 169 html("h=");
170 html_attr(head); 170 html_attr(head);
@@ -446,7 +446,7 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
446 html_hidden("url", url); 446 html_hidden("url", url);
447 } 447 }
448 448
449 if (incl_head && strcmp(ctx.qry.head, cgit_repo->defbranch)) 449 if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch))
450 html_hidden("h", ctx.qry.head); 450 html_hidden("h", ctx.qry.head);
451 451
452 if (ctx.qry.sha1) 452 if (ctx.qry.sha1)
@@ -478,12 +478,12 @@ void cgit_print_pageheader(char *title, int show_search)
478 html("</td></tr>\n<tr><td class='sidebar'>\n"); 478 html("</td></tr>\n<tr><td class='sidebar'>\n");
479 if (ctx.qry.repo) { 479 if (ctx.qry.repo) {
480 html("<h1 class='first'>"); 480 html("<h1 class='first'>");
481 html_txt(strrpart(cgit_repo->name, 20)); 481 html_txt(strrpart(ctx.repo->name, 20));
482 html("</h1>\n"); 482 html("</h1>\n");
483 html_txt(cgit_repo->desc); 483 html_txt(ctx.repo->desc);
484 if (cgit_repo->owner) { 484 if (ctx.repo->owner) {
485 html("<h1>owner</h1>\n"); 485 html("<h1>owner</h1>\n");
486 html_txt(cgit_repo->owner); 486 html_txt(ctx.repo->owner);
487 } 487 }
488 html("<h1>navigate</h1>\n"); 488 html("<h1>navigate</h1>\n");
489 reporevlink(NULL, "summary", NULL, "menu", ctx.qry.head, 489 reporevlink(NULL, "summary", NULL, "menu", ctx.qry.head,
@@ -501,13 +501,13 @@ void cgit_print_pageheader(char *title, int show_search)
501 501
502 for_each_ref(print_archive_ref, &header); 502 for_each_ref(print_archive_ref, &header);
503 503
504 if (cgit_repo->clone_url || ctx.cfg.clone_prefix) { 504 if (ctx.repo->clone_url || ctx.cfg.clone_prefix) {
505 html("<h1>clone</h1>\n"); 505 html("<h1>clone</h1>\n");
506 if (cgit_repo->clone_url) 506 if (ctx.repo->clone_url)
507 url = cgit_repo->clone_url; 507 url = ctx.repo->clone_url;
508 else 508 else
509 url = fmt("%s%s", ctx.cfg.clone_prefix, 509 url = fmt("%s%s", ctx.cfg.clone_prefix,
510 cgit_repo->url); 510 ctx.repo->url);
511 html("<a class='menu' href='"); 511 html("<a class='menu' href='");
512 html_attr(url); 512 html_attr(url);
513 html("' title='"); 513 html("' title='");
diff --git a/ui-summary.c b/ui-summary.c
index 0a44994..3baac08 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -182,9 +182,9 @@ void cgit_print_tags(int maxcount)
182 182
183void cgit_print_summary() 183void cgit_print_summary()
184{ 184{
185 if (cgit_repo->readme) { 185 if (ctx.repo->readme) {
186 html("<div id='summary'>"); 186 html("<div id='summary'>");
187 html_include(cgit_repo->readme); 187 html_include(ctx.repo->readme);
188 html("</div>"); 188 html("</div>");
189 } 189 }
190 if (ctx.cfg.summary_log > 0) 190 if (ctx.cfg.summary_log > 0)
diff --git a/ui-tree.c b/ui-tree.c
index 7cae85a..df05ad3 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -83,7 +83,7 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
83 html("</td><td>"); 83 html("</td><td>");
84 if (S_ISGITLINK(mode)) { 84 if (S_ISGITLINK(mode)) {
85 htmlf("<a class='ls-mod' href='"); 85 htmlf("<a class='ls-mod' href='");
86 html_attr(fmt(cgit_repo->module_link, 86 html_attr(fmt(ctx.repo->module_link,
87 name, 87 name,
88 sha1_to_hex(sha1))); 88 sha1_to_hex(sha1)));
89 html("'>"); 89 html("'>");