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 | ||
