Unified · Split
| @@ -147,6 +147,8 @@ void config_cb(const char *name, const char *value) · 146 unmodified lines | ||
| 147 | 147 | ctx.cfg.enable_filter_overrides = atoi(value); |
| 148 | 148 | else if (!strcmp(name, "enable-gitweb-owner")) |
| 149 | 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 | 152 | else if (!strcmp(name, "enable-index-links")) |
| 151 | 153 | ctx.cfg.enable_index_links = atoi(value); |
| 152 | 154 | else if (!strcmp(name, "enable-commit-graph")) |
| @@ -312,6 +314,7 @@ static void prepare_context(struct cgit_context *ctx) · 159 unmodified lines | ||
| 312 | 314 | ctx->cfg.logo = "/cgit.png"; |
| 313 | 315 | ctx->cfg.local_time = 0; |
| 314 | 316 | ctx->cfg.enable_gitweb_owner = 1; |
| 317 | + ctx->cfg.enable_http_clone = 1; | |
| 315 | 318 | ctx->cfg.enable_tree_linenumbers = 1; |
| 316 | 319 | ctx->cfg.max_repo_count = 50; |
| 317 | 320 | ctx->cfg.max_commit_count = 50; |
| @@ -439,7 +442,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx) · 121 unmodified lines | ||
| 439 | 442 | tmp = xstrdup(ctx->qry.head); |
| 440 | 443 | ctx->qry.head = ctx->repo->defbranch; |
| 441 | 444 | ctx->page.status = 404; |
| 442 | − ctx->page.statusmsg = "not found"; | |
| 445 | + ctx->page.statusmsg = "Not found"; | |
| 443 | 446 | cgit_print_http_headers(ctx); |
| 444 | 447 | cgit_print_docstart(ctx); |
| 445 | 448 | cgit_print_pageheader(ctx); |
| @@ -458,6 +461,8 @@ static void process_request(void *cbdata) · 12 unmodified lines | ||
| 458 | 461 | cmd = cgit_get_cmd(ctx); |
| 459 | 462 | if (!cmd) { |
| 460 | 463 | ctx->page.title = "cgit error"; |
| 464 | + ctx->page.status = 404; | |
| 465 | + ctx->page.statusmsg = "Not found"; | |
| 461 | 466 | cgit_print_http_headers(ctx); |
| 462 | 467 | cgit_print_docstart(ctx); |
| 463 | 468 | cgit_print_pageheader(ctx); |
| @@ -466,6 +471,11 @@ static void process_request(void *cbdata) · 2 unmodified lines | ||
| 466 | 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 | 479 | /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" |
| 470 | 480 | * in-project path limit to be made available at ctx->qry.vpath. |
| 471 | 481 | * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). |
| @@ -191,6 +191,7 @@ struct cgit_config { · 190 unmodified lines | ||
| 191 | 191 | int embedded; |
| 192 | 192 | int enable_filter_overrides; |
| 193 | 193 | int enable_gitweb_owner; |
| 194 | + int enable_http_clone; | |
| 194 | 195 | int enable_index_links; |
| 195 | 196 | int enable_commit_graph; |
| 196 | 197 | int enable_log_filecount; |
| @@ -105,6 +105,11 @@ enable-gitweb-owner:: · 104 unmodified lines | ||
| 105 | 105 | for the git config value "gitweb.owner" to determine the owner. |
| 106 | 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 | 113 | enable-index-links:: |
| 109 | 114 | Flag which, when set to "1", will make cgit generate extra links for |
| 110 | 115 | each repo in the repository index (specifically, to the "summary", |
| @@ -130,31 +130,31 @@ static void tree_fn(struct cgit_context *ctx) · 129 unmodified lines | ||
| 130 | 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) \ | |
| 134 | − {#name, name##_fn, 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, is_clone} | |
| 135 | 135 | |
| 136 | 136 | struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) |
| 137 | 137 | { |
| 138 | 138 | static struct cgit_cmd cmds[] = { |
| 139 | − def_cmd(HEAD, 1, 0, 0), | |
| 140 | − def_cmd(atom, 1, 0, 0), | |
| 141 | − def_cmd(about, 0, 1, 0), | |
| 142 | − def_cmd(blob, 1, 0, 0), | |
| 143 | − def_cmd(commit, 1, 1, 1), | |
| 144 | − def_cmd(diff, 1, 1, 1), | |
| 145 | − def_cmd(info, 1, 0, 0), | |
| 146 | − def_cmd(log, 1, 1, 1), | |
| 147 | − def_cmd(ls_cache, 0, 0, 0), | |
| 148 | − def_cmd(objects, 1, 0, 0), | |
| 149 | − def_cmd(patch, 1, 0, 1), | |
| 150 | − def_cmd(plain, 1, 0, 0), | |
| 151 | − def_cmd(refs, 1, 1, 0), | |
| 152 | − def_cmd(repolist, 0, 0, 0), | |
| 153 | − def_cmd(snapshot, 1, 0, 0), | |
| 154 | − def_cmd(stats, 1, 1, 1), | |
| 155 | − def_cmd(summary, 1, 1, 0), | |
| 156 | − def_cmd(tag, 1, 1, 0), | |
| 157 | − def_cmd(tree, 1, 1, 1), | |
| 139 | + def_cmd(HEAD, 1, 0, 0, 1), | |
| 140 | + def_cmd(atom, 1, 0, 0, 0), | |
| 141 | + def_cmd(about, 0, 1, 0, 0), | |
| 142 | + def_cmd(blob, 1, 0, 0, 0), | |
| 143 | + def_cmd(commit, 1, 1, 1, 0), | |
| 144 | + def_cmd(diff, 1, 1, 1, 0), | |
| 145 | + def_cmd(info, 1, 0, 0, 1), | |
| 146 | + def_cmd(log, 1, 1, 1, 0), | |
| 147 | + def_cmd(ls_cache, 0, 0, 0, 0), | |
| 148 | + def_cmd(objects, 1, 0, 0, 1), | |
| 149 | + def_cmd(patch, 1, 0, 1, 0), | |
| 150 | + def_cmd(plain, 1, 0, 0, 0), | |
| 151 | + def_cmd(refs, 1, 1, 0, 0), | |
| 152 | + def_cmd(repolist, 0, 0, 0, 0), | |
| 153 | + def_cmd(snapshot, 1, 0, 0, 0), | |
| 154 | + def_cmd(stats, 1, 1, 1, 0), | |
| 155 | + def_cmd(summary, 1, 1, 0, 0), | |
| 156 | + def_cmd(tag, 1, 1, 0, 0), | |
| 157 | + def_cmd(tree, 1, 1, 1, 0), | |
| 158 | 158 | }; |
| 159 | 159 | int i; |
| 160 | 160 | |
| @@ -8,7 +8,8 @@ struct cgit_cmd { · 7 unmodified lines | ||
| 8 | 8 | cgit_cmd_fn fn; |
| 9 | 9 | unsigned int want_repo:1, |
| 10 | 10 | want_layout:1, |
| 11 | − want_vpath:1; | |
| 11 | + want_vpath:1, | |
| 12 | + is_clone:1; | |
| 12 | 13 | }; |
| 13 | 14 | |
| 14 | 15 | extern struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx); |