diff options
-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 9 | ||||
-rw-r--r-- | ui-snapshot.c | 8 |
4 files changed, 19 insertions, 2 deletions
@@ -171,6 +171,8 @@ static void config_cb(const char *name, const char *value) ctx.cfg.noheader = atoi(value); else if (!strcmp(name, "snapshots")) ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); + else if (!strcmp(name, "enable-snapshot-prefix")) + ctx.cfg.enable_snapshot_prefix = atoi(value); else if (!strcmp(name, "enable-filter-overrides")) ctx.cfg.enable_filter_overrides = atoi(value); else if (!strcmp(name, "enable-follow-links")) @@ -399,6 +401,7 @@ static void prepare_context(void) ctx.cfg.project_list = NULL; ctx.cfg.renamelimit = -1; ctx.cfg.remove_suffix = 0; + ctx.cfg.enable_snapshot_prefix = 1; ctx.cfg.robots = "index, nofollow"; ctx.cfg.root_title = "Git repository browser"; ctx.cfg.root_desc = "a fast webinterface for the git dscm"; @@ -261,6 +261,7 @@ struct cgit_config { int scan_hidden_path; int section_from_path; int snapshots; + int enable_snapshot_prefix; int section_sort; int summary_branches; int summary_log; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 6f3e952..c1c2126 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -421,6 +421,13 @@ snapshots:: with environment variables, for example set ZSTD_CLEVEL=10 in web server environment for higher (but slower) zstd compression. +enable-snapshot-prefix:: + If set to "1" adds a path prefix inside of generated snapshot archives. + The prefix defaults to the repository name or git ref name and can be + overridden with repo.snapshot-prefix. If set to "0", no such prefix will + be generated, unless this option is overridden with repo.snapshot-prefix. + Default value: "1". See also: snapshots, repo.snapshot-prefix. + source-filter:: Specifies a command which will be invoked to format plaintext blobs in the tree view. The command will get the blob content on its STDIN @@ -606,7 +613,7 @@ repo.snapshot-prefix:: For example, the "linux-stable" repository may wish to set this to "linux" so that snapshots are in the format "linux-3.15.4" instead of "linux-stable-3.15.4". Default value: <empty> meaning to use - the repository basename. + the repository basename. See also: enable-snapshot-prefix repo.source-filter:: Override the default source-filter. Default value: none. See also: diff --git a/ui-snapshot.c b/ui-snapshot.c index 3e38cd5..acae68c 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -308,11 +308,17 @@ void cgit_print_snapshot(const char *head, const char *hex, if (!prefix) prefix = xstrdup(cgit_snapshot_prefix(ctx.repo)); + if (!ctx.cfg.enable_snapshot_prefix && !ctx.repo->snapshot_prefix) { + free(prefix); + prefix = NULL; + } + if (sig_filename) write_sig(f, hex, filename, sig_filename); else make_snapshot(f, hex, prefix, filename); - free(prefix); + if (prefix) + free(prefix); free(adj_filename); } |