Diff options
Diffstat (limited to 'source/cgit.c')
| -rw-r--r-- | source/cgit.c | 22 |
1 file changed, 20 insertions, 2 deletions
diff --git a/source/cgit.c b/source/cgit.c index 41bbad3..17a79a2 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -481,6 +481,24 @@ out: strbuf_release(&cached_rc); } +/* + * Unlike the cgitrc a scanned repository may carry, cgitrc and the files it + * includes are meant to be there, and one that cannot be read would otherwise + * leave nothing but an empty index to go on. + */ +static void parse_cgitrc(const char *filename) +{ + // Copied, since the name usually sits in the buffer macro expansion + // reuses, which a line in the file can overwrite. + char *file = xstrdup(filename); + int err = config_file_parse(file, apply_config); + + if (err) + fprintf(stderr, "[cgit] Unable to read config file %s: %s (%d)\n", + file, strerror(err), err); + free(file); +} + static void add_mimetype(const char *name, const char *value) { struct string_list_item *item; @@ -736,7 +754,7 @@ static void apply_config(const char *name, const char *value) } else if (skip_prefix(name, "mimetype.", &arg)) add_mimetype(arg, value); else if (!strcmp(name, "include")) - config_file_parse(cgit_expand_macros(value), apply_config); + parse_cgitrc(cgit_expand_macros(value)); else if (skip_prefix(name, "repo.", &arg)) fprintf(stderr, "[cgit] Ignoring %s before any repo.url\n", name); else @@ -1365,7 +1383,7 @@ int cmd_main(int argc, const char **argv) prepare_context(); parse_args(argc, argv); - config_file_parse(cgit_expand_macros(ctx.env.cgit_config), apply_config); + parse_cgitrc(cgit_expand_macros(ctx.env.cgit_config)); ctx.repo = NULL; http_parse_querystring(ctx.qry.raw, apply_query_param); |
