diff options
| -rw-r--r-- | cgit.c | 12 | ||||
| -rw-r--r-- | cgit.h | 1 | ||||
| -rw-r--r-- | cgitrc.5.txt | 5 | ||||
| -rw-r--r-- | cmd.c | 42 | ||||
| -rw-r--r-- | cmd.h | 3 |
5 files changed, 40 insertions, 23 deletions
| @@ -147,6 +147,8 @@ void config_cb(const char *name, const char *value) | |||
| 147 | ctx.cfg.enable_filter_overrides = atoi(value); | 147 | ctx.cfg.enable_filter_overrides = atoi(value); |
| 148 | else if (!strcmp(name, "enable-gitweb-owner")) | 148 | else if (!strcmp(name, "enable-gitweb-owner")) |
| 149 | ctx.cfg.enable_gitweb_owner = atoi(value); | 149 | ctx.cfg.enable_gitweb_owner = atoi(value); |
| 150 | else if (!strcmp(name, "enable-http-clone")) | ||
| 151 | ctx.cfg.enable_http_clone = atoi(value); | ||
| 150 | else if (!strcmp(name, "enable-index-links")) | 152 | else if (!strcmp(name, "enable-index-links")) |
| 151 | ctx.cfg.enable_index_links = atoi(value); | 153 | ctx.cfg.enable_index_links = atoi(value); |
| 152 | else if (!strcmp(name, "enable-commit-graph")) | 154 | else if (!strcmp(name, "enable-commit-graph")) |
| @@ -312,6 +314,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
| 312 | ctx->cfg.logo = "/cgit.png"; | 314 | ctx->cfg.logo = "/cgit.png"; |
| 313 | ctx->cfg.local_time = 0; | 315 | ctx->cfg.local_time = 0; |
| 314 | ctx->cfg.enable_gitweb_owner = 1; | 316 | ctx->cfg.enable_gitweb_owner = 1; |
| 317 | ctx->cfg.enable_http_clone = 1; | ||
| 315 | ctx->cfg.enable_tree_linenumbers = 1; | 318 | ctx->cfg.enable_tree_linenumbers = 1; |
| 316 | ctx->cfg.max_repo_count = 50; | 319 | ctx->cfg.max_repo_count = 50; |
| 317 | ctx->cfg.max_commit_count = 50; | 320 | ctx->cfg.max_commit_count = 50; |
| @@ -439,7 +442,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx) | |||
| 439 | tmp = xstrdup(ctx->qry.head); | 442 | tmp = xstrdup(ctx->qry.head); |
| 440 | ctx->qry.head = ctx->repo->defbranch; | 443 | ctx->qry.head = ctx->repo->defbranch; |
| 441 | ctx->page.status = 404; | 444 | ctx->page.status = 404; |
| 442 | ctx->page.statusmsg = "not found"; | 445 | ctx->page.statusmsg = "Not found"; |
| 443 | cgit_print_http_headers(ctx); | 446 | cgit_print_http_headers(ctx); |
| 444 | cgit_print_docstart(ctx); | 447 | cgit_print_docstart(ctx); |
| 445 | cgit_print_pageheader(ctx); | 448 | cgit_print_pageheader(ctx); |
| @@ -458,6 +461,8 @@ static void process_request(void *cbdata) | |||
| 458 | cmd = cgit_get_cmd(ctx); | 461 | cmd = cgit_get_cmd(ctx); |
| 459 | if (!cmd) { | 462 | if (!cmd) { |
| 460 | ctx->page.title = "cgit error"; | 463 | ctx->page.title = "cgit error"; |
| 464 | ctx->page.status = 404; | ||
| 465 | ctx->page.statusmsg = "Not found"; | ||
| 461 | cgit_print_http_headers(ctx); | 466 | cgit_print_http_headers(ctx); |
| 462 | cgit_print_docstart(ctx); | 467 | cgit_print_docstart(ctx); |
| 463 | cgit_print_pageheader(ctx); | 468 | cgit_print_pageheader(ctx); |
| @@ -466,6 +471,11 @@ static void process_request(void *cbdata) | |||
| 466 | return; | 471 | return; |
| 467 | } | 472 | } |
| 468 | 473 | ||
| 474 | if (!ctx->cfg.enable_http_clone && cmd->is_clone) { | ||
| 475 | html_status(404, "Not found", 0); | ||
| 476 | return; | ||
| 477 | } | ||
| 478 | |||
| 469 | /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" | 479 | /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" |
| 470 | * in-project path limit to be made available at ctx->qry.vpath. | 480 | * in-project path limit to be made available at ctx->qry.vpath. |
| 471 | * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). | 481 | * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). |
| @@ -191,6 +191,7 @@ struct cgit_config { | |||
| 191 | int embedded; | 191 | int embedded; |
| 192 | int enable_filter_overrides; | 192 | int enable_filter_overrides; |
| 193 | int enable_gitweb_owner; | 193 | int enable_gitweb_owner; |
| 194 | int enable_http_clone; | ||
| 194 | int enable_index_links; | 195 | int enable_index_links; |
| 195 | int enable_commit_graph; | 196 | int enable_commit_graph; |
| 196 | int enable_log_filecount; | 197 | int enable_log_filecount; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 65b210f..875d51f 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
| @@ -105,6 +105,11 @@ enable-gitweb-owner:: | |||
| 105 | for the git config value "gitweb.owner" to determine the owner. | 105 | for the git config value "gitweb.owner" to determine the owner. |
| 106 | Default value: "1". See also: scan-path. | 106 | Default value: "1". See also: scan-path. |
| 107 | 107 | ||
| 108 | enable-http-clone:: | ||
| 109 | If set to "1", cgit will act as an dumb HTTP endpoint for git clones. | ||
| 110 | If you use an alternate way of serving git repositories, you may wish | ||
| 111 | to disable this. Default value: "1". | ||
| 112 | |||
| 108 | enable-index-links:: | 113 | enable-index-links:: |
| 109 | Flag which, when set to "1", will make cgit generate extra links for | 114 | Flag which, when set to "1", will make cgit generate extra links for |
| 110 | each repo in the repository index (specifically, to the "summary", | 115 | each repo in the repository index (specifically, to the "summary", |
| @@ -130,31 +130,31 @@ static void tree_fn(struct cgit_context *ctx) | |||
| 130 | cgit_print_tree(ctx->qry.sha1, ctx->qry.path); | 130 | cgit_print_tree(ctx->qry.sha1, ctx->qry.path); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | #define def_cmd(name, want_repo, want_layout, want_vpath) \ | 133 | #define def_cmd(name, want_repo, want_layout, want_vpath, is_clone) \ |
| 134 | {#name, name##_fn, want_repo, want_layout, want_vpath} | 134 | {#name, name##_fn, want_repo, want_layout, want_vpath, is_clone} |
| 135 | 135 | ||
| 136 | struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) | 136 | struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) |
| 137 | { | 137 | { |
| 138 | static struct cgit_cmd cmds[] = { | 138 | static struct cgit_cmd cmds[] = { |
| 139 | def_cmd(HEAD, 1, 0, 0), | 139 | def_cmd(HEAD, 1, 0, 0, 1), |
| 140 | def_cmd(atom, 1, 0, 0), | 140 | def_cmd(atom, 1, 0, 0, 0), |
| 141 | def_cmd(about, 0, 1, 0), | 141 | def_cmd(about, 0, 1, 0, 0), |
| 142 | def_cmd(blob, 1, 0, 0), | 142 | def_cmd(blob, 1, 0, 0, 0), |
| 143 | def_cmd(commit, 1, 1, 1), | 143 | def_cmd(commit, 1, 1, 1, 0), |
| 144 | def_cmd(diff, 1, 1, 1), | 144 | def_cmd(diff, 1, 1, 1, 0), |
| 145 | def_cmd(info, 1, 0, 0), | 145 | def_cmd(info, 1, 0, 0, 1), |
| 146 | def_cmd(log, 1, 1, 1), | 146 | def_cmd(log, 1, 1, 1, 0), |
| 147 | def_cmd(ls_cache, 0, 0, 0), | 147 | def_cmd(ls_cache, 0, 0, 0, 0), |
| 148 | def_cmd(objects, 1, 0, 0), | 148 | def_cmd(objects, 1, 0, 0, 1), |
| 149 | def_cmd(patch, 1, 0, 1), | 149 | def_cmd(patch, 1, 0, 1, 0), |
| 150 | def_cmd(plain, 1, 0, 0), | 150 | def_cmd(plain, 1, 0, 0, 0), |
| 151 | def_cmd(refs, 1, 1, 0), | 151 | def_cmd(refs, 1, 1, 0, 0), |
| 152 | def_cmd(repolist, 0, 0, 0), | 152 | def_cmd(repolist, 0, 0, 0, 0), |
| 153 | def_cmd(snapshot, 1, 0, 0), | 153 | def_cmd(snapshot, 1, 0, 0, 0), |
| 154 | def_cmd(stats, 1, 1, 1), | 154 | def_cmd(stats, 1, 1, 1, 0), |
| 155 | def_cmd(summary, 1, 1, 0), | 155 | def_cmd(summary, 1, 1, 0, 0), |
| 156 | def_cmd(tag, 1, 1, 0), | 156 | def_cmd(tag, 1, 1, 0, 0), |
| 157 | def_cmd(tree, 1, 1, 1), | 157 | def_cmd(tree, 1, 1, 1, 0), |
| 158 | }; | 158 | }; |
| 159 | int i; | 159 | int i; |
| 160 | 160 | ||
| @@ -8,7 +8,8 @@ struct cgit_cmd { | |||
| 8 | cgit_cmd_fn fn; | 8 | cgit_cmd_fn fn; |
| 9 | unsigned int want_repo:1, | 9 | unsigned int want_repo:1, |
| 10 | want_layout:1, | 10 | want_layout:1, |
| 11 | want_vpath:1; | 11 | want_vpath:1, |
| 12 | is_clone:1; | ||
| 12 | }; | 13 | }; |
| 13 | 14 | ||
| 14 | extern struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx); | 15 | extern struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx); |
