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 | ||||
-rw-r--r-- | ui-log.c | 29 |
6 files changed, 54 insertions, 38 deletions
diff --git a/cgit.c b/cgit.c index e498030..eb964ac 100644 --- a/cgit.c +++ b/cgit.c | |||
@@ -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). |
diff --git a/cgit.h b/cgit.h index b5f00fc..ecae453 100644 --- a/cgit.h +++ b/cgit.h | |||
@@ -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", |
diff --git a/cmd.c b/cmd.c index 536515b..d114eb3 100644 --- a/cmd.c +++ b/cmd.c | |||
@@ -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 | ||
diff --git a/cmd.h b/cmd.h index 8dc01bd..eb5bc87 100644 --- a/cmd.h +++ b/cmd.h | |||
@@ -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); |
diff --git a/ui-log.c b/ui-log.c index 8add66a..2e6e9d6 100644 --- a/ui-log.c +++ b/ui-log.c | |||
@@ -100,11 +100,10 @@ void print_commit(struct commit *commit, struct rev_info *revs) | |||
100 | struct strbuf graphbuf = STRBUF_INIT; | 100 | struct strbuf graphbuf = STRBUF_INIT; |
101 | struct strbuf msgbuf = STRBUF_INIT; | 101 | struct strbuf msgbuf = STRBUF_INIT; |
102 | 102 | ||
103 | if (ctx.repo->enable_log_filecount) { | 103 | if (ctx.repo->enable_log_filecount) |
104 | cols++; | ||
105 | if (ctx.repo->enable_log_linecount) | ||
104 | cols++; | 106 | cols++; |
105 | if (ctx.repo->enable_log_linecount) | ||
106 | cols++; | ||
107 | } | ||
108 | 107 | ||
109 | if (revs->graph) { | 108 | if (revs->graph) { |
110 | /* Advance graph until current commit */ | 109 | /* Advance graph until current commit */ |
@@ -179,18 +178,18 @@ void print_commit(struct commit *commit, struct rev_info *revs) | |||
179 | html_link_close(); | 178 | html_link_close(); |
180 | } | 179 | } |
181 | 180 | ||
182 | if (ctx.repo->enable_log_filecount) { | 181 | if (ctx.repo->enable_log_filecount || ctx.repo->enable_log_linecount) { |
183 | files = 0; | 182 | files = 0; |
184 | add_lines = 0; | 183 | add_lines = 0; |
185 | rem_lines = 0; | 184 | rem_lines = 0; |
186 | cgit_diff_commit(commit, inspect_files, ctx.qry.vpath); | 185 | cgit_diff_commit(commit, inspect_files, ctx.qry.vpath); |
187 | html("</td><td>"); | ||
188 | htmlf("%d", files); | ||
189 | if (ctx.repo->enable_log_linecount) { | ||
190 | html("</td><td>"); | ||
191 | htmlf("-%d/+%d", rem_lines, add_lines); | ||
192 | } | ||
193 | } | 186 | } |
187 | |||
188 | if (ctx.repo->enable_log_filecount) | ||
189 | htmlf("</td><td>%d", files); | ||
190 | if (ctx.repo->enable_log_linecount) | ||
191 | htmlf("</td><td>-%d/+%d", rem_lines, add_lines); | ||
192 | |||
194 | html("</td></tr>\n"); | 193 | html("</td></tr>\n"); |
195 | 194 | ||
196 | if (revs->graph || ctx.qry.showmsg) { /* Print a second table row */ | 195 | if (revs->graph || ctx.qry.showmsg) { /* Print a second table row */ |
@@ -379,10 +378,10 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
379 | if (ctx.repo->enable_log_filecount) { | 378 | if (ctx.repo->enable_log_filecount) { |
380 | html("<th class='left'>Files</th>"); | 379 | html("<th class='left'>Files</th>"); |
381 | columns++; | 380 | columns++; |
382 | if (ctx.repo->enable_log_linecount) { | 381 | } |
383 | html("<th class='left'>Lines</th>"); | 382 | if (ctx.repo->enable_log_linecount) { |
384 | columns++; | 383 | html("<th class='left'>Lines</th>"); |
385 | } | 384 | columns++; |
386 | } | 385 | } |
387 | html("</tr>\n"); | 386 | html("</tr>\n"); |
388 | 387 | ||