diff options
| -rw-r--r-- | cache.c | 4 | ||||
| -rw-r--r-- | cgit.c | 72 | ||||
| -rw-r--r-- | cgit.h | 35 | ||||
| -rw-r--r-- | parsing.c | 8 | ||||
| -rw-r--r-- | shared.c | 43 | ||||
| -rw-r--r-- | ui-commit.c | 14 | ||||
| -rw-r--r-- | ui-diff.c | 6 | ||||
| -rw-r--r-- | ui-log.c | 20 | ||||
| -rw-r--r-- | ui-patch.c | 2 | ||||
| -rw-r--r-- | ui-refs.c | 4 | ||||
| -rw-r--r-- | ui-shared.c | 86 | ||||
| -rw-r--r-- | ui-summary.c | 6 | ||||
| -rw-r--r-- | ui-tree.c | 20 |
13 files changed, 156 insertions, 164 deletions
| @@ -57,10 +57,10 @@ int cache_create_dirs() | |||
| 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 (cgit_query_page) { | 60 | if (ctx.qry.page) { |
| 61 | path = fmt("%s/%s/%s", cgit_cache_root, | 61 | path = fmt("%s/%s/%s", cgit_cache_root, |
| 62 | cache_safe_filename(cgit_repo->url), | 62 | cache_safe_filename(cgit_repo->url), |
| 63 | cgit_query_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; |
| 66 | } | 66 | } |
| @@ -10,11 +10,11 @@ | |||
| 10 | 10 | ||
| 11 | static int cgit_prepare_cache(struct cacheitem *item) | 11 | 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"); |
| 15 | cgit_print_docstart(title, item); | 15 | cgit_print_docstart(title, 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(); |
| 19 | return 0; | 19 | return 0; |
| 20 | } | 20 | } |
| @@ -28,16 +28,16 @@ static int cgit_prepare_cache(struct cacheitem *item) | |||
| 28 | if (!cgit_cmd) { | 28 | if (!cgit_cmd) { |
| 29 | item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root, | 29 | item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root, |
| 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; |
| 33 | } else { | 33 | } else { |
| 34 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, | 34 | item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, |
| 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; |
| 42 | else | 42 | else |
| 43 | item->ttl = cgit_cache_repo_ttl; | 43 | item->ttl = cgit_cache_repo_ttl; |
| @@ -98,12 +98,12 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 98 | show_search = 0; | 98 | show_search = 0; |
| 99 | setenv("GIT_DIR", cgit_repo->path, 1); | 99 | setenv("GIT_DIR", cgit_repo->path, 1); |
| 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); |
| 108 | cgit_print_pageheader(title, 0); | 108 | cgit_print_pageheader(title, 0); |
| 109 | cgit_print_error("Repository seems to be empty"); | 109 | cgit_print_error("Repository seems to be empty"); |
| @@ -111,9 +111,9 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 111 | return; | 111 | return; |
| 112 | } | 112 | } |
| 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); |
| 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)); |
| @@ -122,20 +122,20 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 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 ); |
| 129 | return; | 129 | return; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 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; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 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; |
| 140 | } | 140 | } |
| 141 | 141 | ||
| @@ -148,28 +148,28 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 148 | return; | 148 | return; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | cgit_print_pageheader(cgit_query_page, show_search); | 151 | cgit_print_pageheader(ctx.qry.page, show_search); |
| 152 | 152 | ||
| 153 | switch(cgit_cmd) { | 153 | switch(cgit_cmd) { |
| 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; |
| 165 | case CMD_REFS: | 165 | case CMD_REFS: |
| 166 | cgit_print_refs(); | 166 | cgit_print_refs(); |
| 167 | break; | 167 | break; |
| 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; |
| 174 | default: | 174 | default: |
| 175 | cgit_print_error("Invalid request"); | 175 | cgit_print_error("Invalid request"); |
| @@ -264,24 +264,24 @@ static void cgit_parse_args(int argc, const char **argv) | |||
| 264 | cgit_nocache = 1; | 264 | cgit_nocache = 1; |
| 265 | } | 265 | } |
| 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 | } |
| 286 | } | 286 | } |
| 287 | } | 287 | } |
| @@ -303,9 +303,9 @@ int main(int argc, const char **argv) | |||
| 303 | if (getenv("SCRIPT_NAME")) | 303 | if (getenv("SCRIPT_NAME")) |
| 304 | cgit_script_name = xstrdup(getenv("SCRIPT_NAME")); | 304 | cgit_script_name = xstrdup(getenv("SCRIPT_NAME")); |
| 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)) |
| 310 | return 0; | 310 | return 0; |
| 311 | if (cgit_nocache) { | 311 | if (cgit_nocache) { |
| @@ -123,10 +123,31 @@ struct reflist { | |||
| 123 | int count; | 123 | int count; |
| 124 | }; | 124 | }; |
| 125 | 125 | ||
| 126 | struct cgit_query { | ||
| 127 | int has_symref; | ||
| 128 | int has_sha1; | ||
| 129 | char *raw; | ||
| 130 | char *repo; | ||
| 131 | char *page; | ||
| 132 | char *search; | ||
| 133 | char *grep; | ||
| 134 | char *head; | ||
| 135 | char *sha1; | ||
| 136 | char *sha2; | ||
| 137 | char *path; | ||
| 138 | char *name; | ||
| 139 | int ofs; | ||
| 140 | }; | ||
| 141 | |||
| 142 | struct cgit_context { | ||
| 143 | struct cgit_query qry; | ||
| 144 | }; | ||
| 145 | |||
| 126 | extern const char *cgit_version; | 146 | extern const char *cgit_version; |
| 127 | 147 | ||
| 128 | extern struct repolist cgit_repolist; | 148 | extern struct repolist cgit_repolist; |
| 129 | extern struct repoinfo *cgit_repo; | 149 | extern struct repoinfo *cgit_repo; |
| 150 | extern struct cgit_context ctx; | ||
| 130 | extern int cgit_cmd; | 151 | extern int cgit_cmd; |
| 131 | 152 | ||
| 132 | extern char *cgit_root_title; | 153 | extern char *cgit_root_title; |
| @@ -163,20 +184,6 @@ extern int cgit_max_msg_len; | |||
| 163 | extern int cgit_max_repodesc_len; | 184 | extern int cgit_max_repodesc_len; |
| 164 | extern int cgit_max_commit_count; | 185 | extern int cgit_max_commit_count; |
| 165 | 186 | ||
| 166 | extern int cgit_query_has_symref; | ||
| 167 | extern int cgit_query_has_sha1; | ||
| 168 | |||
| 169 | extern char *cgit_querystring; | ||
| 170 | extern char *cgit_query_repo; | ||
| 171 | extern char *cgit_query_page; | ||
| 172 | extern char *cgit_query_search; | ||
| 173 | extern char *cgit_query_grep; | ||
| 174 | extern char *cgit_query_head; | ||
| 175 | extern char *cgit_query_sha1; | ||
| 176 | extern char *cgit_query_sha2; | ||
| 177 | extern char *cgit_query_path; | ||
| 178 | extern char *cgit_query_name; | ||
| 179 | extern int cgit_query_ofs; | ||
| 180 | 187 | ||
| 181 | extern int htmlfd; | 188 | extern int htmlfd; |
| 182 | 189 | ||
| @@ -149,7 +149,7 @@ void cgit_parse_url(const char *url) | |||
| 149 | 149 | ||
| 150 | cgit_repo = cgit_get_repoinfo(url); | 150 | cgit_repo = cgit_get_repoinfo(url); |
| 151 | if (cgit_repo) { | 151 | if (cgit_repo) { |
| 152 | cgit_query_repo = cgit_repo->url; | 152 | ctx.qry.repo = cgit_repo->url; |
| 153 | return; | 153 | return; |
| 154 | } | 154 | } |
| 155 | 155 | ||
| @@ -163,15 +163,15 @@ void cgit_parse_url(const char *url) | |||
| 163 | continue; | 163 | continue; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | cgit_query_repo = cgit_repo->url; | 166 | ctx.qry.repo = cgit_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'; |
| 170 | if (p[1]) | 170 | if (p[1]) |
| 171 | cgit_query_path = trim_end(p + 1, '/'); | 171 | ctx.qry.path = trim_end(p + 1, '/'); |
| 172 | } | 172 | } |
| 173 | cgit_cmd = cgit_get_cmd_index(cmd + 1); | 173 | cgit_cmd = cgit_get_cmd_index(cmd + 1); |
| 174 | cgit_query_page = xstrdup(cmd + 1); | 174 | ctx.qry.page = xstrdup(cmd + 1); |
| 175 | return; | 175 | return; |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | struct repolist cgit_repolist; | 11 | struct repolist cgit_repolist; |
| 12 | struct repoinfo *cgit_repo; | 12 | struct repoinfo *cgit_repo; |
| 13 | struct cgit_context ctx; | ||
| 13 | int cgit_cmd; | 14 | int cgit_cmd; |
| 14 | 15 | ||
| 15 | const char *cgit_version = CGIT_VERSION; | 16 | const char *cgit_version = CGIT_VERSION; |
| @@ -49,24 +50,8 @@ int cgit_max_msg_len = 60; | |||
| 49 | int cgit_max_repodesc_len = 60; | 50 | int cgit_max_repodesc_len = 60; |
| 50 | int cgit_max_commit_count = 50; | 51 | int cgit_max_commit_count = 50; |
| 51 | 52 | ||
| 52 | int cgit_query_has_symref = 0; | ||
| 53 | int cgit_query_has_sha1 = 0; | ||
| 54 | |||
| 55 | char *cgit_querystring = NULL; | ||
| 56 | char *cgit_query_repo = NULL; | ||
| 57 | char *cgit_query_page = NULL; | ||
| 58 | char *cgit_query_head = NULL; | ||
| 59 | char *cgit_query_search = NULL; | ||
| 60 | char *cgit_query_grep = NULL; | ||
| 61 | char *cgit_query_sha1 = NULL; | ||
| 62 | char *cgit_query_sha2 = NULL; | ||
| 63 | char *cgit_query_path = NULL; | ||
| 64 | char *cgit_query_name = NULL; | ||
| 65 | int cgit_query_ofs = 0; | ||
| 66 | |||
| 67 | int htmlfd = 0; | 53 | int htmlfd = 0; |
| 68 | 54 | ||
| 69 | |||
| 70 | int cgit_get_cmd_index(const char *cmd) | 55 | int cgit_get_cmd_index(const char *cmd) |
| 71 | { | 56 | { |
| 72 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", | 57 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
| @@ -239,32 +224,32 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
| 239 | void cgit_querystring_cb(const char *name, const char *value) | 224 | void cgit_querystring_cb(const char *name, const char *value) |
| 240 | { | 225 | { |
| 241 | if (!strcmp(name,"r")) { | 226 | if (!strcmp(name,"r")) { |
| 242 | cgit_query_repo = xstrdup(value); | 227 | ctx.qry.repo = xstrdup(value); |
| 243 | cgit_repo = cgit_get_repoinfo(value); | 228 | cgit_repo = cgit_get_repoinfo(value); |
| 244 | } else if (!strcmp(name, "p")) { | 229 | } else if (!strcmp(name, "p")) { |
| 245 | cgit_query_page = xstrdup(value); | 230 | ctx.qry.page = xstrdup(value); |
| 246 | cgit_cmd = cgit_get_cmd_index(value); | 231 | cgit_cmd = cgit_get_cmd_index(value); |
| 247 | } else if (!strcmp(name, "url")) { | 232 | } else if (!strcmp(name, "url")) { |
| 248 | cgit_parse_url(value); | 233 | cgit_parse_url(value); |
| 249 | } else if (!strcmp(name, "qt")) { | 234 | } else if (!strcmp(name, "qt")) { |
| 250 | cgit_query_grep = xstrdup(value); | 235 | ctx.qry.grep = xstrdup(value); |
| 251 | } else if (!strcmp(name, "q")) { | 236 | } else if (!strcmp(name, "q")) { |
| 252 | cgit_query_search = xstrdup(value); | 237 | ctx.qry.search = xstrdup(value); |
| 253 | } else if (!strcmp(name, "h")) { | 238 | } else if (!strcmp(name, "h")) { |
| 254 | cgit_query_head = xstrdup(value); | 239 | ctx.qry.head = xstrdup(value); |
| 255 | cgit_query_has_symref = 1; | 240 | ctx.qry.has_symref = 1; |
| 256 | } else if (!strcmp(name, "id")) { | 241 | } else if (!strcmp(name, "id")) { |
| 257 | cgit_query_sha1 = xstrdup(value); | 242 | ctx.qry.sha1 = xstrdup(value); |
| 258 | cgit_query_has_sha1 = 1; | 243 | ctx.qry.has_sha1 = 1; |
| 259 | } else if (!strcmp(name, "id2")) { | 244 | } else if (!strcmp(name, "id2")) { |
| 260 | cgit_query_sha2 = xstrdup(value); | 245 | ctx.qry.sha2 = xstrdup(value); |
| 261 | cgit_query_has_sha1 = 1; | 246 | ctx.qry.has_sha1 = 1; |
| 262 | } else if (!strcmp(name, "ofs")) { | 247 | } else if (!strcmp(name, "ofs")) { |
| 263 | cgit_query_ofs = atoi(value); | 248 | ctx.qry.ofs = atoi(value); |
| 264 | } else if (!strcmp(name, "path")) { | 249 | } else if (!strcmp(name, "path")) { |
| 265 | cgit_query_path = trim_end(value, '/'); | 250 | ctx.qry.path = trim_end(value, '/'); |
| 266 | } else if (!strcmp(name, "name")) { | 251 | } else if (!strcmp(name, "name")) { |
| 267 | cgit_query_name = xstrdup(value); | 252 | ctx.qry.name = xstrdup(value); |
| 268 | } | 253 | } |
| 269 | } | 254 | } |
| 270 | 255 | ||
diff --git a/ui-commit.c b/ui-commit.c index bd55a33..3b0919b 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
| @@ -75,7 +75,7 @@ void print_fileinfo(struct fileinfo *info) | |||
| 75 | html("]</span>"); | 75 | html("]</span>"); |
| 76 | } | 76 | } |
| 77 | htmlf("</td><td class='%s'>", class); | 77 | htmlf("</td><td class='%s'>", class); |
| 78 | cgit_diff_link(info->new_path, NULL, NULL, cgit_query_head, curr_rev, | 78 | cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, curr_rev, |
| 79 | NULL, info->new_path); | 79 | NULL, info->new_path); |
| 80 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) | 80 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) |
| 81 | htmlf(" (%s from %s)", | 81 | htmlf(" (%s from %s)", |
| @@ -143,7 +143,7 @@ void cgit_print_commit(char *hex) | |||
| 143 | int i; | 143 | int i; |
| 144 | 144 | ||
| 145 | if (!hex) | 145 | if (!hex) |
| 146 | hex = cgit_query_head; | 146 | hex = ctx.qry.head; |
| 147 | curr_rev = hex; | 147 | curr_rev = hex; |
| 148 | 148 | ||
| 149 | if (get_sha1(hex, sha1)) { | 149 | if (get_sha1(hex, sha1)) { |
| @@ -175,7 +175,7 @@ void cgit_print_commit(char *hex) | |||
| 175 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); | 175 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); |
| 176 | tmp = xstrdup(hex); | 176 | tmp = xstrdup(hex); |
| 177 | cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, | 177 | cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, |
| 178 | cgit_query_head, tmp, NULL); | 178 | ctx.qry.head, tmp, NULL); |
| 179 | html("</td></tr>\n"); | 179 | html("</td></tr>\n"); |
| 180 | for (p = commit->parents; p ; p = p->next) { | 180 | for (p = commit->parents; p ; p = p->next) { |
| 181 | parent = lookup_commit_reference(p->item->object.sha1); | 181 | parent = lookup_commit_reference(p->item->object.sha1); |
| @@ -188,15 +188,15 @@ void cgit_print_commit(char *hex) | |||
| 188 | html("<tr><th>parent</th>" | 188 | html("<tr><th>parent</th>" |
| 189 | "<td colspan='2' class='sha1'>"); | 189 | "<td colspan='2' class='sha1'>"); |
| 190 | cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, | 190 | cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, |
| 191 | cgit_query_head, sha1_to_hex(p->item->object.sha1)); | 191 | ctx.qry.head, sha1_to_hex(p->item->object.sha1)); |
| 192 | html(" ("); | 192 | html(" ("); |
| 193 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, hex, | 193 | cgit_diff_link("diff", NULL, NULL, ctx.qry.head, 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 (cgit_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(cgit_query_repo, cgit_query_head, | 199 | cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, |
| 200 | hex, cgit_repo->snapshots); | 200 | hex, cgit_repo->snapshots); |
| 201 | html("</td></tr>"); | 201 | html("</td></tr>"); |
| 202 | } | 202 | } |
| @@ -218,7 +218,7 @@ void cgit_print_commit(char *hex) | |||
| 218 | html("<div class='diffstat-summary'>"); | 218 | html("<div class='diffstat-summary'>"); |
| 219 | htmlf("%d files changed, %d insertions, %d deletions (", | 219 | htmlf("%d files changed, %d insertions, %d deletions (", |
| 220 | files, total_adds, total_rems); | 220 | files, total_adds, total_rems); |
| 221 | cgit_diff_link("show diff", NULL, NULL, cgit_query_head, hex, | 221 | cgit_diff_link("show diff", NULL, NULL, ctx.qry.head, hex, |
| 222 | NULL, NULL); | 222 | NULL, NULL); |
| 223 | html(")</div>"); | 223 | html(")</div>"); |
| 224 | } | 224 | } |
| @@ -71,13 +71,13 @@ static void header(unsigned char *sha1, char *path1, int mode1, | |||
| 71 | } | 71 | } |
| 72 | html("<br/>--- a/"); | 72 | html("<br/>--- a/"); |
| 73 | if (mode1 != 0) | 73 | if (mode1 != 0) |
| 74 | cgit_tree_link(path1, NULL, NULL, cgit_query_head, | 74 | cgit_tree_link(path1, NULL, NULL, ctx.qry.head, |
| 75 | sha1_to_hex(old_rev_sha1), path1); | 75 | sha1_to_hex(old_rev_sha1), path1); |
| 76 | else | 76 | else |
| 77 | html_txt(path1); | 77 | html_txt(path1); |
| 78 | html("<br/>+++ b/"); | 78 | html("<br/>+++ b/"); |
| 79 | if (mode2 != 0) | 79 | if (mode2 != 0) |
| 80 | cgit_tree_link(path2, NULL, NULL, cgit_query_head, | 80 | cgit_tree_link(path2, NULL, NULL, ctx.qry.head, |
| 81 | sha1_to_hex(new_rev_sha1), path2); | 81 | sha1_to_hex(new_rev_sha1), path2); |
| 82 | else | 82 | else |
| 83 | html_txt(path2); | 83 | html_txt(path2); |
| @@ -107,7 +107,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi | |||
| 107 | struct commit *commit, *commit2; | 107 | struct commit *commit, *commit2; |
| 108 | 108 | ||
| 109 | if (!new_rev) | 109 | if (!new_rev) |
| 110 | new_rev = cgit_query_head; | 110 | new_rev = ctx.qry.head; |
| 111 | get_sha1(new_rev, new_rev_sha1); | 111 | get_sha1(new_rev, new_rev_sha1); |
| 112 | type = sha1_object_info(new_rev_sha1, &size); | 112 | type = sha1_object_info(new_rev_sha1, &size); |
| 113 | if (type == OBJ_BAD) { | 113 | if (type == OBJ_BAD) { |
| @@ -37,7 +37,7 @@ void print_commit(struct commit *commit) | |||
| 37 | html("<tr><td>"); | 37 | html("<tr><td>"); |
| 38 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); | 38 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
| 39 | html("</td><td>"); | 39 | html("</td><td>"); |
| 40 | cgit_commit_link(info->subject, NULL, NULL, cgit_query_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 (cgit_repo->enable_log_filecount) { |
| 43 | files = 0; | 43 | files = 0; |
| @@ -67,7 +67,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
| 67 | int i; | 67 | int i; |
| 68 | 68 | ||
| 69 | if (!tip) | 69 | if (!tip) |
| 70 | argv[1] = cgit_query_head; | 70 | argv[1] = ctx.qry.head; |
| 71 | 71 | ||
| 72 | if (grep && pattern && (!strcmp(grep, "grep") || | 72 | if (grep && pattern && (!strcmp(grep, "grep") || |
| 73 | !strcmp(grep, "author") || | 73 | !strcmp(grep, "author") || |
| @@ -123,17 +123,17 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
| 123 | if (pager) { | 123 | if (pager) { |
| 124 | html("<div class='pager'>"); | 124 | html("<div class='pager'>"); |
| 125 | if (ofs > 0) { | 125 | if (ofs > 0) { |
| 126 | cgit_log_link("[prev]", NULL, NULL, cgit_query_head, | 126 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
| 127 | cgit_query_sha1, cgit_query_path, | 127 | ctx.qry.sha1, ctx.qry.path, |
| 128 | ofs - cnt, cgit_query_grep, | 128 | ofs - cnt, ctx.qry.grep, |
| 129 | cgit_query_search); | 129 | ctx.qry.search); |
| 130 | html(" "); | 130 | html(" "); |
| 131 | } | 131 | } |
| 132 | if ((commit = get_revision(&rev)) != NULL) { | 132 | if ((commit = get_revision(&rev)) != NULL) { |
| 133 | cgit_log_link("[next]", NULL, NULL, cgit_query_head, | 133 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
| 134 | cgit_query_sha1, cgit_query_path, | 134 | ctx.qry.sha1, ctx.qry.path, |
| 135 | ofs + cnt, cgit_query_grep, | 135 | ofs + cnt, ctx.qry.grep, |
| 136 | cgit_query_search); | 136 | ctx.qry.search); |
| 137 | } | 137 | } |
| 138 | html("</div>"); | 138 | html("</div>"); |
| 139 | } | 139 | } |
| @@ -76,7 +76,7 @@ void cgit_print_patch(char *hex, struct cacheitem *item) | |||
| 76 | char *patchname; | 76 | char *patchname; |
| 77 | 77 | ||
| 78 | if (!hex) | 78 | if (!hex) |
| 79 | hex = cgit_query_head; | 79 | hex = ctx.qry.head; |
| 80 | 80 | ||
| 81 | if (get_sha1(hex, sha1)) { | 81 | if (get_sha1(hex, sha1)) { |
| 82 | cgit_print_error(fmt("Bad object id: %s", hex)); | 82 | cgit_print_error(fmt("Bad object id: %s", hex)); |
| @@ -16,9 +16,9 @@ void cgit_print_refs() | |||
| 16 | 16 | ||
| 17 | html("<table class='list nowrap'>"); | 17 | html("<table class='list nowrap'>"); |
| 18 | 18 | ||
| 19 | if (cgit_query_path && !strncmp(cgit_query_path, "heads", 5)) | 19 | if (ctx.qry.path && !strncmp(ctx.qry.path, "heads", 5)) |
| 20 | cgit_print_branches(0); | 20 | cgit_print_branches(0); |
| 21 | else if (cgit_query_path && !strncmp(cgit_query_path, "tags", 4)) | 21 | else if (ctx.qry.path && !strncmp(ctx.qry.path, "tags", 4)) |
| 22 | cgit_print_tags(0); | 22 | cgit_print_tags(0); |
| 23 | else { | 23 | else { |
| 24 | cgit_print_branches(0); | 24 | cgit_print_branches(0); |
diff --git a/ui-shared.c b/ui-shared.c index 60aa2e3..6a41fb0 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
| @@ -112,10 +112,10 @@ char *cgit_currurl() | |||
| 112 | { | 112 | { |
| 113 | if (!cgit_virtual_root) | 113 | if (!cgit_virtual_root) |
| 114 | return cgit_script_name; | 114 | return cgit_script_name; |
| 115 | else if (cgit_query_page) | 115 | else if (ctx.qry.page) |
| 116 | return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page); | 116 | return fmt("%s/%s/%s/", cgit_virtual_root, ctx.qry.repo, ctx.qry.page); |
| 117 | else if (cgit_query_repo) | 117 | else if (ctx.qry.repo) |
| 118 | return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo); | 118 | return fmt("%s/%s/", cgit_virtual_root, ctx.qry.repo); |
| 119 | else | 119 | else |
| 120 | return fmt("%s/", cgit_virtual_root); | 120 | return fmt("%s/", cgit_virtual_root); |
| 121 | } | 121 | } |
| @@ -179,7 +179,7 @@ static void reporevlink(char *page, char *name, char *title, char *class, | |||
| 179 | char *delim; | 179 | char *delim; |
| 180 | 180 | ||
| 181 | delim = repolink(title, class, page, head, path); | 181 | delim = repolink(title, class, page, head, path); |
| 182 | if (rev && strcmp(rev, cgit_query_head)) { | 182 | if (rev && strcmp(rev, ctx.qry.head)) { |
| 183 | html(delim); | 183 | html(delim); |
| 184 | html("id="); | 184 | html("id="); |
| 185 | html_attr(rev); | 185 | html_attr(rev); |
| @@ -201,7 +201,7 @@ void cgit_log_link(char *name, char *title, char *class, char *head, | |||
| 201 | char *delim; | 201 | char *delim; |
| 202 | 202 | ||
| 203 | delim = repolink(title, class, "log", head, path); | 203 | delim = repolink(title, class, "log", head, path); |
| 204 | if (rev && strcmp(rev, cgit_query_head)) { | 204 | if (rev && strcmp(rev, ctx.qry.head)) { |
| 205 | html(delim); | 205 | html(delim); |
| 206 | html("id="); | 206 | html("id="); |
| 207 | html_attr(rev); | 207 | html_attr(rev); |
| @@ -256,7 +256,7 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
| 256 | char *delim; | 256 | char *delim; |
| 257 | 257 | ||
| 258 | delim = repolink(title, class, "diff", head, path); | 258 | delim = repolink(title, class, "diff", head, path); |
| 259 | if (new_rev && strcmp(new_rev, cgit_query_head)) { | 259 | if (new_rev && strcmp(new_rev, ctx.qry.head)) { |
| 260 | html(delim); | 260 | html(delim); |
| 261 | html("id="); | 261 | html("id="); |
| 262 | html_attr(new_rev); | 262 | html_attr(new_rev); |
| @@ -284,7 +284,7 @@ void cgit_object_link(struct object *obj) | |||
| 284 | 284 | ||
| 285 | if (obj->type == OBJ_COMMIT) { | 285 | if (obj->type == OBJ_COMMIT) { |
| 286 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, | 286 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, |
| 287 | cgit_query_head, sha1_to_hex(obj->sha1)); | 287 | ctx.qry.head, sha1_to_hex(obj->sha1)); |
| 288 | return; | 288 | return; |
| 289 | } else if (obj->type == OBJ_TREE) { | 289 | } else if (obj->type == OBJ_TREE) { |
| 290 | page = "tree"; | 290 | page = "tree"; |
| @@ -297,7 +297,7 @@ void cgit_object_link(struct object *obj) | |||
| 297 | arg = "id"; | 297 | arg = "id"; |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | url = cgit_pageurl(cgit_query_repo, page, | 300 | url = cgit_pageurl(ctx.qry.repo, page, |
| 301 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | 301 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); |
| 302 | html_link_open(url, NULL, NULL); | 302 | html_link_open(url, NULL, NULL); |
| 303 | htmlf("%s %s", typename(obj->type), | 303 | htmlf("%s %s", typename(obj->type), |
| @@ -392,7 +392,7 @@ int print_branch_option(const char *refname, const unsigned char *sha1, | |||
| 392 | int flags, void *cb_data) | 392 | int flags, void *cb_data) |
| 393 | { | 393 | { |
| 394 | char *name = (char *)refname; | 394 | char *name = (char *)refname; |
| 395 | html_option(name, name, cgit_query_head); | 395 | html_option(name, name, ctx.qry.head); |
| 396 | return 0; | 396 | return 0; |
| 397 | } | 397 | } |
| 398 | 398 | ||
| @@ -426,7 +426,7 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, | |||
| 426 | html("<h1>download</h1>\n"); | 426 | html("<h1>download</h1>\n"); |
| 427 | *header = 1; | 427 | *header = 1; |
| 428 | } | 428 | } |
| 429 | url = cgit_pageurl(cgit_query_repo, "blob", | 429 | url = cgit_pageurl(ctx.qry.repo, "blob", |
| 430 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 430 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
| 431 | buf)); | 431 | buf)); |
| 432 | html_link_open(url, NULL, "menu"); | 432 | html_link_open(url, NULL, "menu"); |
| @@ -440,25 +440,25 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page) | |||
| 440 | char *url; | 440 | char *url; |
| 441 | 441 | ||
| 442 | if (!cgit_virtual_root) { | 442 | if (!cgit_virtual_root) { |
| 443 | url = fmt("%s/%s", cgit_query_repo, page); | 443 | url = fmt("%s/%s", ctx.qry.repo, page); |
| 444 | if (cgit_query_path) | 444 | if (ctx.qry.path) |
| 445 | url = fmt("%s/%s", url, cgit_query_path); | 445 | url = fmt("%s/%s", url, ctx.qry.path); |
| 446 | html_hidden("url", url); | 446 | html_hidden("url", url); |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) | 449 | if (incl_head && strcmp(ctx.qry.head, cgit_repo->defbranch)) |
| 450 | html_hidden("h", cgit_query_head); | 450 | html_hidden("h", ctx.qry.head); |
| 451 | 451 | ||
| 452 | if (cgit_query_sha1) | 452 | if (ctx.qry.sha1) |
| 453 | html_hidden("id", cgit_query_sha1); | 453 | html_hidden("id", ctx.qry.sha1); |
| 454 | if (cgit_query_sha2) | 454 | if (ctx.qry.sha2) |
| 455 | html_hidden("id2", cgit_query_sha2); | 455 | html_hidden("id2", ctx.qry.sha2); |
| 456 | 456 | ||
| 457 | if (incl_search) { | 457 | if (incl_search) { |
| 458 | if (cgit_query_grep) | 458 | if (ctx.qry.grep) |
| 459 | html_hidden("qt", cgit_query_grep); | 459 | html_hidden("qt", ctx.qry.grep); |
| 460 | if (cgit_query_search) | 460 | if (ctx.qry.search) |
| 461 | html_hidden("q", cgit_query_search); | 461 | html_hidden("q", ctx.qry.search); |
| 462 | } | 462 | } |
| 463 | } | 463 | } |
| 464 | 464 | ||
| @@ -476,7 +476,7 @@ void cgit_print_pageheader(char *title, int show_search) | |||
| 476 | htmlf("'><img src='%s' alt='cgit'/></a>\n", | 476 | htmlf("'><img src='%s' alt='cgit'/></a>\n", |
| 477 | cgit_logo); | 477 | cgit_logo); |
| 478 | html("</td></tr>\n<tr><td class='sidebar'>\n"); | 478 | html("</td></tr>\n<tr><td class='sidebar'>\n"); |
| 479 | if (cgit_query_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(cgit_repo->name, 20)); |
| 482 | html("</h1>\n"); | 482 | html("</h1>\n"); |
| @@ -486,18 +486,18 @@ void cgit_print_pageheader(char *title, int show_search) | |||
| 486 | html_txt(cgit_repo->owner); | 486 | html_txt(cgit_repo->owner); |
| 487 | } | 487 | } |
| 488 | html("<h1>navigate</h1>\n"); | 488 | html("<h1>navigate</h1>\n"); |
| 489 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, | 489 | reporevlink(NULL, "summary", NULL, "menu", ctx.qry.head, |
| 490 | NULL, NULL); | 490 | NULL, NULL); |
| 491 | cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, | 491 | cgit_log_link("log", NULL, "menu", ctx.qry.head, NULL, NULL, |
| 492 | 0, NULL, NULL); | 492 | 0, NULL, NULL); |
| 493 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, | 493 | cgit_tree_link("tree", NULL, "menu", ctx.qry.head, |
| 494 | cgit_query_sha1, NULL); | 494 | ctx.qry.sha1, NULL); |
| 495 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, | 495 | cgit_commit_link("commit", NULL, "menu", ctx.qry.head, |
| 496 | cgit_query_sha1); | 496 | ctx.qry.sha1); |
| 497 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, | 497 | cgit_diff_link("diff", NULL, "menu", ctx.qry.head, |
| 498 | cgit_query_sha1, cgit_query_sha2, NULL); | 498 | ctx.qry.sha1, ctx.qry.sha2, NULL); |
| 499 | cgit_patch_link("patch", NULL, "menu", cgit_query_head, | 499 | cgit_patch_link("patch", NULL, "menu", ctx.qry.head, |
| 500 | cgit_query_sha1); | 500 | ctx.qry.sha1); |
| 501 | 501 | ||
| 502 | for_each_ref(print_archive_ref, &header); | 502 | for_each_ref(print_archive_ref, &header); |
| 503 | 503 | ||
| @@ -519,10 +519,10 @@ void cgit_print_pageheader(char *title, int show_search) | |||
| 519 | 519 | ||
| 520 | html("<h1>branch</h1>\n"); | 520 | html("<h1>branch</h1>\n"); |
| 521 | html("<form method='get' action=''>\n"); | 521 | html("<form method='get' action=''>\n"); |
| 522 | add_hidden_formfields(0, 1, cgit_query_page); | 522 | add_hidden_formfields(0, 1, ctx.qry.page); |
| 523 | // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); | 523 | // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); |
| 524 | html("<select name='h' onchange='this.form.submit();'>\n"); | 524 | html("<select name='h' onchange='this.form.submit();'>\n"); |
| 525 | for_each_branch_ref(print_branch_option, cgit_query_head); | 525 | for_each_branch_ref(print_branch_option, ctx.qry.head); |
| 526 | html("</select>\n"); | 526 | html("</select>\n"); |
| 527 | // html("</td><td>"); | 527 | // html("</td><td>"); |
| 528 | html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n"); | 528 | html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n"); |
| @@ -532,17 +532,17 @@ void cgit_print_pageheader(char *title, int show_search) | |||
| 532 | html("<h1>search</h1>\n"); | 532 | html("<h1>search</h1>\n"); |
| 533 | html("<form method='get' action='"); | 533 | html("<form method='get' action='"); |
| 534 | if (cgit_virtual_root) | 534 | if (cgit_virtual_root) |
| 535 | html_attr(cgit_fileurl(cgit_query_repo, "log", | 535 | html_attr(cgit_fileurl(ctx.qry.repo, "log", |
| 536 | cgit_query_path, NULL)); | 536 | ctx.qry.path, NULL)); |
| 537 | html("'>\n"); | 537 | html("'>\n"); |
| 538 | add_hidden_formfields(1, 0, "log"); | 538 | add_hidden_formfields(1, 0, "log"); |
| 539 | html("<select name='qt'>\n"); | 539 | html("<select name='qt'>\n"); |
| 540 | html_option("grep", "log msg", cgit_query_grep); | 540 | html_option("grep", "log msg", ctx.qry.grep); |
| 541 | html_option("author", "author", cgit_query_grep); | 541 | html_option("author", "author", ctx.qry.grep); |
| 542 | html_option("committer", "committer", cgit_query_grep); | 542 | html_option("committer", "committer", ctx.qry.grep); |
| 543 | html("</select>\n"); | 543 | html("</select>\n"); |
| 544 | html("<input class='txt' type='text' name='q' value='"); | 544 | html("<input class='txt' type='text' name='q' value='"); |
| 545 | html_attr(cgit_query_search); | 545 | html_attr(ctx.qry.search); |
| 546 | html("'/>\n"); | 546 | html("'/>\n"); |
| 547 | html("</form>\n"); | 547 | html("</form>\n"); |
| 548 | } else { | 548 | } else { |
diff --git a/ui-summary.c b/ui-summary.c index b96414e..bbd4464 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
| @@ -94,7 +94,7 @@ static int print_tag(struct refinfo *ref) | |||
| 94 | if (!tag || !info) | 94 | if (!tag || !info) |
| 95 | return 1; | 95 | return 1; |
| 96 | html("<tr><td>"); | 96 | html("<tr><td>"); |
| 97 | url = cgit_pageurl(cgit_query_repo, "tag", | 97 | url = cgit_pageurl(ctx.qry.repo, "tag", |
| 98 | fmt("id=%s", name)); | 98 | fmt("id=%s", name)); |
| 99 | html_link_open(url, NULL, NULL); | 99 | html_link_open(url, NULL, NULL); |
| 100 | html_txt(name); | 100 | html_txt(name); |
| @@ -123,7 +123,7 @@ static int print_tag(struct refinfo *ref) | |||
| 123 | static void print_refs_link(char *path) | 123 | static void print_refs_link(char *path) |
| 124 | { | 124 | { |
| 125 | html("<tr class='nohover'><td colspan='4'>"); | 125 | html("<tr class='nohover'><td colspan='4'>"); |
| 126 | cgit_refs_link("[...]", NULL, NULL, cgit_query_head, NULL, path); | 126 | cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); |
| 127 | html("</td></tr>"); | 127 | html("</td></tr>"); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| @@ -188,7 +188,7 @@ void cgit_print_summary() | |||
| 188 | html("</div>"); | 188 | html("</div>"); |
| 189 | } | 189 | } |
| 190 | if (cgit_summary_log > 0) | 190 | if (cgit_summary_log > 0) |
| 191 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, | 191 | cgit_print_log(ctx.qry.head, 0, cgit_summary_log, NULL, |
| 192 | NULL, NULL, 0); | 192 | NULL, NULL, 0); |
| 193 | html("<table summary='repository info' class='list nowrap'>"); | 193 | html("<table summary='repository info' class='list nowrap'>"); |
| 194 | if (cgit_summary_log > 0) | 194 | if (cgit_summary_log > 0) |
| @@ -34,7 +34,7 @@ static void print_object(const unsigned char *sha1, char *path) | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | html(" blob: <a href='"); | 36 | html(" blob: <a href='"); |
| 37 | html_attr(cgit_pageurl(cgit_query_repo, "blob", fmt("id=%s", sha1_to_hex(sha1)))); | 37 | html_attr(cgit_pageurl(ctx.qry.repo, "blob", fmt("id=%s", sha1_to_hex(sha1)))); |
| 38 | htmlf("'>%s</a>",sha1_to_hex(sha1)); | 38 | htmlf("'>%s</a>",sha1_to_hex(sha1)); |
| 39 | 39 | ||
| 40 | html("<table summary='blob content' class='blob'>\n"); | 40 | html("<table summary='blob content' class='blob'>\n"); |
| @@ -67,8 +67,8 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, | |||
| 67 | unsigned long size = 0; | 67 | unsigned long size = 0; |
| 68 | 68 | ||
| 69 | name = xstrdup(pathname); | 69 | name = xstrdup(pathname); |
| 70 | fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "", | 70 | fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", |
| 71 | cgit_query_path ? "/" : "", name); | 71 | ctx.qry.path ? "/" : "", name); |
| 72 | 72 | ||
| 73 | type = sha1_object_info(sha1, &size); | 73 | type = sha1_object_info(sha1, &size); |
| 74 | if (type == OBJ_BAD && !S_ISGITLINK(mode)) { | 74 | if (type == OBJ_BAD && !S_ISGITLINK(mode)) { |
| @@ -90,16 +90,16 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, | |||
| 90 | html_txt(name); | 90 | html_txt(name); |
| 91 | html("</a>"); | 91 | html("</a>"); |
| 92 | } else if (S_ISDIR(mode)) { | 92 | } else if (S_ISDIR(mode)) { |
| 93 | cgit_tree_link(name, NULL, "ls-dir", cgit_query_head, | 93 | cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, |
| 94 | curr_rev, fullpath); | 94 | curr_rev, fullpath); |
| 95 | } else { | 95 | } else { |
| 96 | cgit_tree_link(name, NULL, "ls-blob", cgit_query_head, | 96 | cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, |
| 97 | curr_rev, fullpath); | 97 | curr_rev, fullpath); |
| 98 | } | 98 | } |
| 99 | htmlf("</td><td class='ls-size'>%li</td>", size); | 99 | htmlf("</td><td class='ls-size'>%li</td>", size); |
| 100 | 100 | ||
| 101 | html("<td>"); | 101 | html("<td>"); |
| 102 | cgit_log_link("log", NULL, "button", cgit_query_head, curr_rev, | 102 | cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, |
| 103 | fullpath, 0, NULL, NULL); | 103 | fullpath, 0, NULL, NULL); |
| 104 | html("</td></tr>\n"); | 104 | html("</td></tr>\n"); |
| 105 | free(name); | 105 | free(name); |
| @@ -153,10 +153,10 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen, | |||
| 153 | if (state == 0) { | 153 | if (state == 0) { |
| 154 | memcpy(buffer, base, baselen); | 154 | memcpy(buffer, base, baselen); |
| 155 | strcpy(buffer+baselen, pathname); | 155 | strcpy(buffer+baselen, pathname); |
| 156 | url = cgit_pageurl(cgit_query_repo, "tree", | 156 | url = cgit_pageurl(ctx.qry.repo, "tree", |
| 157 | fmt("h=%s&path=%s", curr_rev, buffer)); | 157 | fmt("h=%s&path=%s", curr_rev, buffer)); |
| 158 | html("/"); | 158 | html("/"); |
| 159 | cgit_tree_link(xstrdup(pathname), NULL, NULL, cgit_query_head, | 159 | cgit_tree_link(xstrdup(pathname), NULL, NULL, ctx.qry.head, |
| 160 | curr_rev, buffer); | 160 | curr_rev, buffer); |
| 161 | 161 | ||
| 162 | if (strcmp(match_path, buffer)) | 162 | if (strcmp(match_path, buffer)) |
| @@ -188,7 +188,7 @@ void cgit_print_tree(const char *rev, char *path) | |||
| 188 | const char *paths[] = {path, NULL}; | 188 | const char *paths[] = {path, NULL}; |
| 189 | 189 | ||
| 190 | if (!rev) | 190 | if (!rev) |
| 191 | rev = cgit_query_head; | 191 | rev = ctx.qry.head; |
| 192 | 192 | ||
| 193 | curr_rev = xstrdup(rev); | 193 | curr_rev = xstrdup(rev); |
| 194 | if (get_sha1(rev, sha1)) { | 194 | if (get_sha1(rev, sha1)) { |
| @@ -202,7 +202,7 @@ void cgit_print_tree(const char *rev, char *path) | |||
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | html("path: <a href='"); | 204 | html("path: <a href='"); |
| 205 | html_attr(cgit_pageurl(cgit_query_repo, "tree", fmt("h=%s", rev))); | 205 | html_attr(cgit_pageurl(ctx.qry.repo, "tree", fmt("h=%s", rev))); |
| 206 | html("'>root</a>"); | 206 | html("'>root</a>"); |
| 207 | 207 | ||
| 208 | if (path == NULL) { | 208 | if (path == NULL) { |
