aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-09-19 15:23:28 +0200
committerLinnea Gräf <nea@nea.moe>2024-09-19 15:28:18 +0200
commit0f11492868791513cbaae69c6476a00647f3fd47 (patch)
treebb1328076fd7d1091c1b63563cf76c8f7b936527
parent09d24d7cd0b7e85633f2f43808b12871bb209d69 (diff)
downloadcgit-0f11492868791513cbaae69c6476a00647f3fd47.tar.gz
cgit-0f11492868791513cbaae69c6476a00647f3fd47.tar.bz2
cgit-0f11492868791513cbaae69c6476a00647f3fd47.zip
ui-snapshot: add option to disable prefixHEADmaster
Hi everyone, it is me, ui snapshot prefix remover 3000 here today coming at you with another git patch
-rw-r--r--cgit.c3
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt9
-rw-r--r--ui-snapshot.c8
4 files changed, 19 insertions, 2 deletions
diff --git a/cgit.c b/cgit.c
index 2efa962..f2127e0 100644
--- a/cgit.c
+++ b/cgit.c
@@ -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";
diff --git a/cgit.h b/cgit.h
index e0d286d..26cba6d 100644
--- a/cgit.h
+++ b/cgit.h
@@ -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);
}