diff options
-rw-r--r-- | cgit.c | 39 | ||||
-rw-r--r-- | cgit.css | 27 | ||||
-rw-r--r-- | cgit.h | 7 | ||||
-rw-r--r-- | cgitrc.5.txt | 52 | ||||
-rw-r--r-- | cmd.c | 44 | ||||
-rw-r--r-- | cmd.h | 3 | ||||
-rwxr-xr-x | filters/commit-links.sh | 11 | ||||
-rwxr-xr-x | filters/syntax-highlighting.sh | 11 | ||||
-rw-r--r-- | html.c | 8 | ||||
-rw-r--r-- | html.h | 1 | ||||
-rw-r--r-- | shared.c | 32 | ||||
-rw-r--r-- | ui-commit.c | 16 | ||||
-rw-r--r-- | ui-diff.c | 83 | ||||
-rw-r--r-- | ui-diff.h | 4 | ||||
-rw-r--r-- | ui-log.c | 29 | ||||
-rw-r--r-- | ui-repolist.c | 17 | ||||
-rw-r--r-- | ui-snapshot.c | 2 | ||||
-rw-r--r-- | ui-stats.c | 51 | ||||
-rw-r--r-- | ui-summary.c | 2 | ||||
-rw-r--r-- | ui-tree.c | 2 |
20 files changed, 317 insertions, 124 deletions
@@ -26,14 +26,27 @@ void add_mimetype(const char *name, const char *value) | |||
26 | item->util = xstrdup(value); | 26 | item->util = xstrdup(value); |
27 | } | 27 | } |
28 | 28 | ||
29 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | 29 | struct cgit_filter *new_filter(const char *cmd, filter_type filtertype) |
30 | { | 30 | { |
31 | struct cgit_filter *f; | 31 | struct cgit_filter *f; |
32 | int args_size = 0; | 32 | int args_size = 0; |
33 | int extra_args; | ||
33 | 34 | ||
34 | if (!cmd || !cmd[0]) | 35 | if (!cmd || !cmd[0]) |
35 | return NULL; | 36 | return NULL; |
36 | 37 | ||
38 | switch (filtertype) { | ||
39 | case SOURCE: | ||
40 | extra_args = 1; | ||
41 | break; | ||
42 | |||
43 | case ABOUT: | ||
44 | case COMMIT: | ||
45 | default: | ||
46 | extra_args = 0; | ||
47 | break; | ||
48 | } | ||
49 | |||
37 | f = xmalloc(sizeof(struct cgit_filter)); | 50 | f = xmalloc(sizeof(struct cgit_filter)); |
38 | f->cmd = xstrdup(cmd); | 51 | f->cmd = xstrdup(cmd); |
39 | args_size = (2 + extra_args) * sizeof(char *); | 52 | args_size = (2 + extra_args) * sizeof(char *); |
@@ -83,11 +96,11 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
83 | repo->logo_link = xstrdup(value); | 96 | repo->logo_link = xstrdup(value); |
84 | else if (ctx.cfg.enable_filter_overrides) { | 97 | else if (ctx.cfg.enable_filter_overrides) { |
85 | if (!strcmp(name, "about-filter")) | 98 | if (!strcmp(name, "about-filter")) |
86 | repo->about_filter = new_filter(value, 0); | 99 | repo->about_filter = new_filter(value, ABOUT); |
87 | else if (!strcmp(name, "commit-filter")) | 100 | else if (!strcmp(name, "commit-filter")) |
88 | repo->commit_filter = new_filter(value, 0); | 101 | repo->commit_filter = new_filter(value, COMMIT); |
89 | else if (!strcmp(name, "source-filter")) | 102 | else if (!strcmp(name, "source-filter")) |
90 | repo->source_filter = new_filter(value, 1); | 103 | repo->source_filter = new_filter(value, SOURCE); |
91 | } | 104 | } |
92 | } | 105 | } |
93 | 106 | ||
@@ -147,6 +160,8 @@ void config_cb(const char *name, const char *value) | |||
147 | ctx.cfg.enable_filter_overrides = atoi(value); | 160 | ctx.cfg.enable_filter_overrides = atoi(value); |
148 | else if (!strcmp(name, "enable-gitweb-owner")) | 161 | else if (!strcmp(name, "enable-gitweb-owner")) |
149 | ctx.cfg.enable_gitweb_owner = atoi(value); | 162 | ctx.cfg.enable_gitweb_owner = atoi(value); |
163 | else if (!strcmp(name, "enable-http-clone")) | ||
164 | ctx.cfg.enable_http_clone = atoi(value); | ||
150 | else if (!strcmp(name, "enable-index-links")) | 165 | else if (!strcmp(name, "enable-index-links")) |
151 | ctx.cfg.enable_index_links = atoi(value); | 166 | ctx.cfg.enable_index_links = atoi(value); |
152 | else if (!strcmp(name, "enable-commit-graph")) | 167 | else if (!strcmp(name, "enable-commit-graph")) |
@@ -178,9 +193,9 @@ void config_cb(const char *name, const char *value) | |||
178 | else if (!strcmp(name, "cache-dynamic-ttl")) | 193 | else if (!strcmp(name, "cache-dynamic-ttl")) |
179 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 194 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
180 | else if (!strcmp(name, "about-filter")) | 195 | else if (!strcmp(name, "about-filter")) |
181 | ctx.cfg.about_filter = new_filter(value, 0); | 196 | ctx.cfg.about_filter = new_filter(value, ABOUT); |
182 | else if (!strcmp(name, "commit-filter")) | 197 | else if (!strcmp(name, "commit-filter")) |
183 | ctx.cfg.commit_filter = new_filter(value, 0); | 198 | ctx.cfg.commit_filter = new_filter(value, COMMIT); |
184 | else if (!strcmp(name, "embedded")) | 199 | else if (!strcmp(name, "embedded")) |
185 | ctx.cfg.embedded = atoi(value); | 200 | ctx.cfg.embedded = atoi(value); |
186 | else if (!strcmp(name, "max-atom-items")) | 201 | else if (!strcmp(name, "max-atom-items")) |
@@ -210,7 +225,7 @@ void config_cb(const char *name, const char *value) | |||
210 | else if (!strcmp(name, "section-from-path")) | 225 | else if (!strcmp(name, "section-from-path")) |
211 | ctx.cfg.section_from_path = atoi(value); | 226 | ctx.cfg.section_from_path = atoi(value); |
212 | else if (!strcmp(name, "source-filter")) | 227 | else if (!strcmp(name, "source-filter")) |
213 | ctx.cfg.source_filter = new_filter(value, 1); | 228 | ctx.cfg.source_filter = new_filter(value, SOURCE); |
214 | else if (!strcmp(name, "summary-log")) | 229 | else if (!strcmp(name, "summary-log")) |
215 | ctx.cfg.summary_log = atoi(value); | 230 | ctx.cfg.summary_log = atoi(value); |
216 | else if (!strcmp(name, "summary-branches")) | 231 | else if (!strcmp(name, "summary-branches")) |
@@ -312,6 +327,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
312 | ctx->cfg.logo = "/cgit.png"; | 327 | ctx->cfg.logo = "/cgit.png"; |
313 | ctx->cfg.local_time = 0; | 328 | ctx->cfg.local_time = 0; |
314 | ctx->cfg.enable_gitweb_owner = 1; | 329 | ctx->cfg.enable_gitweb_owner = 1; |
330 | ctx->cfg.enable_http_clone = 1; | ||
315 | ctx->cfg.enable_tree_linenumbers = 1; | 331 | ctx->cfg.enable_tree_linenumbers = 1; |
316 | ctx->cfg.max_repo_count = 50; | 332 | ctx->cfg.max_repo_count = 50; |
317 | ctx->cfg.max_commit_count = 50; | 333 | ctx->cfg.max_commit_count = 50; |
@@ -439,7 +455,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx) | |||
439 | tmp = xstrdup(ctx->qry.head); | 455 | tmp = xstrdup(ctx->qry.head); |
440 | ctx->qry.head = ctx->repo->defbranch; | 456 | ctx->qry.head = ctx->repo->defbranch; |
441 | ctx->page.status = 404; | 457 | ctx->page.status = 404; |
442 | ctx->page.statusmsg = "not found"; | 458 | ctx->page.statusmsg = "Not found"; |
443 | cgit_print_http_headers(ctx); | 459 | cgit_print_http_headers(ctx); |
444 | cgit_print_docstart(ctx); | 460 | cgit_print_docstart(ctx); |
445 | cgit_print_pageheader(ctx); | 461 | cgit_print_pageheader(ctx); |
@@ -458,6 +474,8 @@ static void process_request(void *cbdata) | |||
458 | cmd = cgit_get_cmd(ctx); | 474 | cmd = cgit_get_cmd(ctx); |
459 | if (!cmd) { | 475 | if (!cmd) { |
460 | ctx->page.title = "cgit error"; | 476 | ctx->page.title = "cgit error"; |
477 | ctx->page.status = 404; | ||
478 | ctx->page.statusmsg = "Not found"; | ||
461 | cgit_print_http_headers(ctx); | 479 | cgit_print_http_headers(ctx); |
462 | cgit_print_docstart(ctx); | 480 | cgit_print_docstart(ctx); |
463 | cgit_print_pageheader(ctx); | 481 | cgit_print_pageheader(ctx); |
@@ -466,6 +484,11 @@ static void process_request(void *cbdata) | |||
466 | return; | 484 | return; |
467 | } | 485 | } |
468 | 486 | ||
487 | if (!ctx->cfg.enable_http_clone && cmd->is_clone) { | ||
488 | html_status(404, "Not found", 0); | ||
489 | return; | ||
490 | } | ||
491 | |||
469 | /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" | 492 | /* 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. | 493 | * in-project path limit to be made available at ctx->qry.vpath. |
471 | * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). | 494 | * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). |
@@ -331,6 +331,33 @@ table.commit-info { | |||
331 | margin-top: 1.5em; | 331 | margin-top: 1.5em; |
332 | } | 332 | } |
333 | 333 | ||
334 | div.cgit-panel { | ||
335 | float: right; | ||
336 | margin-top: 1.5em; | ||
337 | } | ||
338 | |||
339 | div.cgit-panel table { | ||
340 | border-collapse: collapse; | ||
341 | border: solid 1px #aaa; | ||
342 | background-color: #eee; | ||
343 | } | ||
344 | |||
345 | div.cgit-panel th { | ||
346 | text-align: center; | ||
347 | } | ||
348 | |||
349 | div.cgit-panel td { | ||
350 | padding: 0.25em 0.5em; | ||
351 | } | ||
352 | |||
353 | div.cgit-panel td.label { | ||
354 | padding-right: 0.5em; | ||
355 | } | ||
356 | |||
357 | div.cgit-panel td.ctrl { | ||
358 | padding-left: 0.5em; | ||
359 | } | ||
360 | |||
334 | table.commit-info th { | 361 | table.commit-info th { |
335 | text-align: left; | 362 | text-align: left; |
336 | font-weight: normal; | 363 | font-weight: normal; |
@@ -51,6 +51,10 @@ typedef void (*configfn)(const char *name, const char *value); | |||
51 | typedef void (*filepair_fn)(struct diff_filepair *pair); | 51 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
52 | typedef void (*linediff_fn)(char *line, int len); | 52 | typedef void (*linediff_fn)(char *line, int len); |
53 | 53 | ||
54 | typedef enum { | ||
55 | ABOUT, COMMIT, SOURCE | ||
56 | } filter_type; | ||
57 | |||
54 | struct cgit_filter { | 58 | struct cgit_filter { |
55 | char *cmd; | 59 | char *cmd; |
56 | char **argv; | 60 | char **argv; |
@@ -191,6 +195,7 @@ struct cgit_config { | |||
191 | int embedded; | 195 | int embedded; |
192 | int enable_filter_overrides; | 196 | int enable_filter_overrides; |
193 | int enable_gitweb_owner; | 197 | int enable_gitweb_owner; |
198 | int enable_http_clone; | ||
194 | int enable_index_links; | 199 | int enable_index_links; |
195 | int enable_commit_graph; | 200 | int enable_commit_graph; |
196 | int enable_log_filecount; | 201 | int enable_log_filecount; |
@@ -314,7 +319,7 @@ extern const char *cgit_repobasename(const char *reponame); | |||
314 | 319 | ||
315 | extern int cgit_parse_snapshots_mask(const char *str); | 320 | extern int cgit_parse_snapshots_mask(const char *str); |
316 | 321 | ||
317 | extern int cgit_open_filter(struct cgit_filter *filter); | 322 | extern int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo); |
318 | extern int cgit_close_filter(struct cgit_filter *filter); | 323 | extern int cgit_close_filter(struct cgit_filter *filter); |
319 | 324 | ||
320 | extern int readfile(const char *path, char **buf, size_t *size); | 325 | extern int readfile(const char *path, char **buf, size_t *size); |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 65b210f..5903a93 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -31,7 +31,7 @@ about-filter:: | |||
31 | about pages (both top-level and for each repository). The command will | 31 | about pages (both top-level and for each repository). The command will |
32 | get the content of the about-file on its STDIN, and the STDOUT from the | 32 | get the content of the about-file on its STDIN, and the STDOUT from the |
33 | command will be included verbatim on the about page. Default value: | 33 | command will be included verbatim on the about page. Default value: |
34 | none. | 34 | none. See also: "FILTER API". |
35 | 35 | ||
36 | agefile:: | 36 | agefile:: |
37 | Specifies a path, relative to each repository path, which can be used | 37 | Specifies a path, relative to each repository path, which can be used |
@@ -81,6 +81,7 @@ commit-filter:: | |||
81 | The command will get the message on its STDIN, and the STDOUT from the | 81 | The command will get the message on its STDIN, and the STDOUT from the |
82 | command will be included verbatim as the commit message, i.e. this can | 82 | command will be included verbatim as the commit message, i.e. this can |
83 | be used to implement bugtracker integration. Default value: none. | 83 | be used to implement bugtracker integration. Default value: none. |
84 | See also: "FILTER API". | ||
84 | 85 | ||
85 | css:: | 86 | css:: |
86 | Url which specifies the css document to include in all cgit pages. | 87 | Url which specifies the css document to include in all cgit pages. |
@@ -105,6 +106,11 @@ enable-gitweb-owner:: | |||
105 | for the git config value "gitweb.owner" to determine the owner. | 106 | for the git config value "gitweb.owner" to determine the owner. |
106 | Default value: "1". See also: scan-path. | 107 | Default value: "1". See also: scan-path. |
107 | 108 | ||
109 | enable-http-clone:: | ||
110 | If set to "1", cgit will act as an dumb HTTP endpoint for git clones. | ||
111 | If you use an alternate way of serving git repositories, you may wish | ||
112 | to disable this. Default value: "1". | ||
113 | |||
108 | enable-index-links:: | 114 | enable-index-links:: |
109 | Flag which, when set to "1", will make cgit generate extra links for | 115 | Flag which, when set to "1", will make cgit generate extra links for |
110 | each repo in the repository index (specifically, to the "summary", | 116 | each repo in the repository index (specifically, to the "summary", |
@@ -318,7 +324,7 @@ source-filter:: | |||
318 | and the name of the blob as its only command line argument. The STDOUT | 324 | and the name of the blob as its only command line argument. The STDOUT |
319 | from the command will be included verbatim as the blob contents, i.e. | 325 | from the command will be included verbatim as the blob contents, i.e. |
320 | this can be used to implement e.g. syntax highlighting. Default value: | 326 | this can be used to implement e.g. syntax highlighting. Default value: |
321 | none. | 327 | none. See also: "FILTER API". |
322 | 328 | ||
323 | summary-branches:: | 329 | summary-branches:: |
324 | Specifies the number of branches to display in the repository "summary" | 330 | Specifies the number of branches to display in the repository "summary" |
@@ -351,7 +357,7 @@ REPOSITORY SETTINGS | |||
351 | ------------------- | 357 | ------------------- |
352 | repo.about-filter:: | 358 | repo.about-filter:: |
353 | Override the default about-filter. Default value: none. See also: | 359 | Override the default about-filter. Default value: none. See also: |
354 | "enable-filter-overrides". | 360 | "enable-filter-overrides". See also: "FILTER API". |
355 | 361 | ||
356 | repo.clone-url:: | 362 | repo.clone-url:: |
357 | A list of space-separated urls which can be used to clone this repo. | 363 | A list of space-separated urls which can be used to clone this repo. |
@@ -359,7 +365,7 @@ repo.clone-url:: | |||
359 | 365 | ||
360 | repo.commit-filter:: | 366 | repo.commit-filter:: |
361 | Override the default commit-filter. Default value: none. See also: | 367 | Override the default commit-filter. Default value: none. See also: |
362 | "enable-filter-overrides". | 368 | "enable-filter-overrides". See also: "FILTER API". |
363 | 369 | ||
364 | repo.defbranch:: | 370 | repo.defbranch:: |
365 | The name of the default branch for this repository. If no such branch | 371 | The name of the default branch for this repository. If no such branch |
@@ -430,7 +436,7 @@ repo.section:: | |||
430 | 436 | ||
431 | repo.source-filter:: | 437 | repo.source-filter:: |
432 | Override the default source-filter. Default value: none. See also: | 438 | Override the default source-filter. Default value: none. See also: |
433 | "enable-filter-overrides". | 439 | "enable-filter-overrides". See also: "FILTER API". |
434 | 440 | ||
435 | repo.url:: | 441 | repo.url:: |
436 | The relative url used to access the repository. This must be the first | 442 | The relative url used to access the repository. This must be the first |
@@ -450,6 +456,42 @@ Note: the "repo." prefix is dropped from the option names in repo-specific | |||
450 | config files, e.g. "repo.desc" becomes "desc". | 456 | config files, e.g. "repo.desc" becomes "desc". |
451 | 457 | ||
452 | 458 | ||
459 | FILTER API | ||
460 | ---------- | ||
461 | - about filter:: | ||
462 | This filter is given no arguments. | ||
463 | The about text that is to be filtered is available on standard input and the | ||
464 | filtered text is expected on standard output. | ||
465 | - commit filter:: | ||
466 | This filter is given no arguments. | ||
467 | The commit message text that is to be filtered is available on standard input | ||
468 | and the filtered text is expected on standard output. | ||
469 | - source filter:: | ||
470 | This filter is given a single parameter: the filename of the source file to | ||
471 | filter. The filter can use the filename to determine (for example) the syntax | ||
472 | highlighting mode. | ||
473 | The contents of the source file that is to be filtered is available on | ||
474 | standard input and the filtered contents is expected on standard output. | ||
475 | |||
476 | Also, all filters are handed the following environment variables: | ||
477 | - CGIT_REPO_URL ( = repo.url setting ) | ||
478 | - CGIT_REPO_NAME ( = repo.name setting ) | ||
479 | - CGIT_REPO_PATH ( = repo.path setting ) | ||
480 | - CGIT_REPO_OWNER ( = repo.owner setting ) | ||
481 | - CGIT_REPO_DEFBRANCH ( = repo.defbranch setting ) | ||
482 | - CGIT_REPO_SECTION ( = section setting ) | ||
483 | - CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) | ||
484 | |||
485 | If a setting is not defined for a repository and the corresponding global | ||
486 | setting is also not defined (if applicable), then the corresponding | ||
487 | environment variable will be an empty string. | ||
488 | |||
489 | Note that under normal circumstance all these environment variables are | ||
490 | defined. If however the total size of the defined settings exceed the | ||
491 | allocated buffer within cgit then only the environment variables that fit | ||
492 | in the allocated buffer are handed to the filter. | ||
493 | |||
494 | |||
453 | EXAMPLE CGITRC FILE | 495 | EXAMPLE CGITRC FILE |
454 | ------------------- | 496 | ------------------- |
455 | 497 | ||
@@ -56,7 +56,7 @@ static void commit_fn(struct cgit_context *ctx) | |||
56 | 56 | ||
57 | static void diff_fn(struct cgit_context *ctx) | 57 | static void diff_fn(struct cgit_context *ctx) |
58 | { | 58 | { |
59 | cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path); | 59 | cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1); |
60 | } | 60 | } |
61 | 61 | ||
62 | static void info_fn(struct cgit_context *ctx) | 62 | static void info_fn(struct cgit_context *ctx) |
@@ -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); |
diff --git a/filters/commit-links.sh b/filters/commit-links.sh index 110c609..d2cd2b3 100755 --- a/filters/commit-links.sh +++ b/filters/commit-links.sh | |||
@@ -3,6 +3,17 @@ | |||
3 | # | 3 | # |
4 | # To use this script, refer to this file with either the commit-filter or the | 4 | # To use this script, refer to this file with either the commit-filter or the |
5 | # repo.commit-filter options in cgitrc. | 5 | # repo.commit-filter options in cgitrc. |
6 | # | ||
7 | # The following environment variables can be used to retrieve the configuration | ||
8 | # of the repository for which this script is called: | ||
9 | # CGIT_REPO_URL ( = repo.url setting ) | ||
10 | # CGIT_REPO_NAME ( = repo.name setting ) | ||
11 | # CGIT_REPO_PATH ( = repo.path setting ) | ||
12 | # CGIT_REPO_OWNER ( = repo.owner setting ) | ||
13 | # CGIT_REPO_DEFBRANCH ( = repo.defbranch setting ) | ||
14 | # CGIT_REPO_SECTION ( = section setting ) | ||
15 | # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) | ||
16 | # | ||
6 | 17 | ||
7 | # This expression generates links to commits referenced by their SHA1. | 18 | # This expression generates links to commits referenced by their SHA1. |
8 | regex=$regex' | 19 | regex=$regex' |
diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh index 6b1c576..6283ce9 100755 --- a/filters/syntax-highlighting.sh +++ b/filters/syntax-highlighting.sh | |||
@@ -23,6 +23,17 @@ | |||
23 | # table.blob .kwb { color:#830000; } | 23 | # table.blob .kwb { color:#830000; } |
24 | # table.blob .kwc { color:#000000; font-weight:bold; } | 24 | # table.blob .kwc { color:#000000; font-weight:bold; } |
25 | # table.blob .kwd { color:#010181; } | 25 | # table.blob .kwd { color:#010181; } |
26 | # | ||
27 | # The following environment variables can be used to retrieve the configuration | ||
28 | # of the repository for which this script is called: | ||
29 | # CGIT_REPO_URL ( = repo.url setting ) | ||
30 | # CGIT_REPO_NAME ( = repo.name setting ) | ||
31 | # CGIT_REPO_PATH ( = repo.path setting ) | ||
32 | # CGIT_REPO_OWNER ( = repo.owner setting ) | ||
33 | # CGIT_REPO_DEFBRANCH ( = repo.defbranch setting ) | ||
34 | # CGIT_REPO_SECTION ( = section setting ) | ||
35 | # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) | ||
36 | # | ||
26 | 37 | ||
27 | # store filename and extension in local vars | 38 | # store filename and extension in local vars |
28 | BASENAME="$1" | 39 | BASENAME="$1" |
@@ -215,6 +215,14 @@ void html_option(const char *value, const char *text, const char *selected_value | |||
215 | html("</option>\n"); | 215 | html("</option>\n"); |
216 | } | 216 | } |
217 | 217 | ||
218 | void html_intoption(int value, const char *text, int selected_value) | ||
219 | { | ||
220 | htmlf("<option value='%d'%s>", value, | ||
221 | value == selected_value ? " selected='selected'" : ""); | ||
222 | html_txt(text); | ||
223 | html("</option>"); | ||
224 | } | ||
225 | |||
218 | void html_link_open(const char *url, const char *title, const char *class) | 226 | void html_link_open(const char *url, const char *title, const char *class) |
219 | { | 227 | { |
220 | html("<a href='"); | 228 | html("<a href='"); |
@@ -17,6 +17,7 @@ extern void html_url_path(const char *txt); | |||
17 | extern void html_url_arg(const char *txt); | 17 | extern void html_url_arg(const char *txt); |
18 | extern void html_hidden(const char *name, const char *value); | 18 | extern void html_hidden(const char *name, const char *value); |
19 | extern void html_option(const char *value, const char *text, const char *selected_value); | 19 | extern void html_option(const char *value, const char *text, const char *selected_value); |
20 | extern void html_intoption(int value, const char *text, int selected_value); | ||
20 | extern void html_link_open(const char *url, const char *title, const char *class); | 21 | extern void html_link_open(const char *url, const char *title, const char *class); |
21 | extern void html_link_close(void); | 22 | extern void html_link_close(void); |
22 | extern void html_fileperm(unsigned short mode); | 23 | extern void html_fileperm(unsigned short mode); |
@@ -7,6 +7,8 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include <stdio.h> | ||
11 | #include <linux/limits.h> | ||
10 | 12 | ||
11 | struct cgit_repolist cgit_repolist; | 13 | struct cgit_repolist cgit_repolist; |
12 | struct cgit_context ctx; | 14 | struct cgit_context ctx; |
@@ -367,7 +369,33 @@ int cgit_parse_snapshots_mask(const char *str) | |||
367 | return rv; | 369 | return rv; |
368 | } | 370 | } |
369 | 371 | ||
370 | int cgit_open_filter(struct cgit_filter *filter) | 372 | typedef struct { |
373 | char * name; | ||
374 | char * value; | ||
375 | } cgit_env_var; | ||
376 | |||
377 | static void prepare_env(struct cgit_repo * repo) { | ||
378 | cgit_env_var env_vars[] = { | ||
379 | { .name = "CGIT_REPO_URL", .value = repo->url }, | ||
380 | { .name = "CGIT_REPO_NAME", .value = repo->name }, | ||
381 | { .name = "CGIT_REPO_PATH", .value = repo->path }, | ||
382 | { .name = "CGIT_REPO_OWNER", .value = repo->owner }, | ||
383 | { .name = "CGIT_REPO_DEFBRANCH", .value = repo->defbranch }, | ||
384 | { .name = "CGIT_REPO_SECTION", .value = repo->section }, | ||
385 | { .name = "CGIT_REPO_CLONE_URL", .value = repo->clone_url } | ||
386 | }; | ||
387 | int env_var_count = ARRAY_SIZE(env_vars); | ||
388 | cgit_env_var *p, *q; | ||
389 | static char *warn = "cgit warning: failed to set env: %s=%s\n"; | ||
390 | |||
391 | p = env_vars; | ||
392 | q = p + env_var_count; | ||
393 | for (; p < q; p++) | ||
394 | if (setenv(p->name, p->value, 1)) | ||
395 | fprintf(stderr, warn, p->name, p->value); | ||
396 | } | ||
397 | |||
398 | int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo) | ||
371 | { | 399 | { |
372 | 400 | ||
373 | filter->old_stdout = chk_positive(dup(STDOUT_FILENO), | 401 | filter->old_stdout = chk_positive(dup(STDOUT_FILENO), |
@@ -378,6 +406,8 @@ int cgit_open_filter(struct cgit_filter *filter) | |||
378 | close(filter->pipe_fh[1]); | 406 | close(filter->pipe_fh[1]); |
379 | chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO), | 407 | chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO), |
380 | "Unable to use pipe as STDIN"); | 408 | "Unable to use pipe as STDIN"); |
409 | if (repo) | ||
410 | prepare_env(repo); | ||
381 | execvp(filter->cmd, filter->argv); | 411 | execvp(filter->cmd, filter->argv); |
382 | die("Unable to exec subprocess %s: %s (%d)", filter->cmd, | 412 | die("Unable to exec subprocess %s: %s (%d)", filter->cmd, |
383 | strerror(errno), errno); | 413 | strerror(errno), errno); |
diff --git a/ui-commit.c b/ui-commit.c index 2b4f677..a69dec6 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -39,7 +39,8 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
39 | format_note(NULL, sha1, ¬es, PAGE_ENCODING, 0); | 39 | format_note(NULL, sha1, ¬es, PAGE_ENCODING, 0); |
40 | 40 | ||
41 | load_ref_decorations(DECORATE_FULL_REFS); | 41 | load_ref_decorations(DECORATE_FULL_REFS); |
42 | 42 | ||
43 | cgit_print_diff_ctrls(); | ||
43 | html("<table summary='commit info' class='commit-info'>\n"); | 44 | html("<table summary='commit info' class='commit-info'>\n"); |