From 6fdd3c789aa039a1439ec65bdde6a56ddd88c59d Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 4 Nov 2026 22:33:58 -1000 Subject: Report a snapshot format name that matches nothing --- source/ui-snapshot.c | 13 +++++++++++++ source/ui-snapshot.h | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/ui-snapshot.c b/source/ui-snapshot.c index 333bce6..910bee6 100644 --- a/source/ui-snapshot.c +++ b/source/ui-snapshot.c @@ -13,6 +13,7 @@ #define USE_THE_REPOSITORY_VARIABLE #include "cgit.h" +#include "config.h" #include "filter.h" #include "html.h" #include "shared.h" @@ -321,6 +322,7 @@ int cgit_parse_snapshots_mask(const char *str) struct string_list_item *item; const struct cgit_snapshot_format *f; int mask = 0; + int len; // A number is the legacy form of this setting and is still taken // ahead of the named forms below. @@ -340,6 +342,17 @@ int cgit_parse_snapshots_mask(const char *str) break; } } + // A 0 is the legacy form offering none, and stays quiet. + if (f->suffix || !strcmp(item->string, "0")) + continue; + // The first line alone, since a git config value can hold a + // newline that would forge a log line of its own. + len = (int)strcspn(item->string, "\n"); + if (config_origin.file) + fprintf(stderr, "[cgit] Ignoring unknown snapshot format %.*s in %s line %d\n", + len, item->string, config_origin.file, config_origin.line); + else + fprintf(stderr, "[cgit] Ignoring unknown snapshot format %.*s\n", len, item->string); } string_list_clear(&tokens, 0); diff --git a/source/ui-snapshot.h b/source/ui-snapshot.h index 12241a9..3edc9a9 100644 --- a/source/ui-snapshot.h +++ b/source/ui-snapshot.h @@ -29,7 +29,8 @@ extern unsigned cgit_snapshot_format_bit(const struct cgit_snapshot_format *f); * Turn a cgitrc snapshots value into a mask over cgit_snapshot_formats. A * plain non-zero number is the legacy boolean form and enables plain tar * alone, the word all enables every format, and otherwise the value is a - * space separated list of suffixes. + * space separated list of suffixes, where a name matching no format is + * logged with the file and line it came from. */ extern int cgit_parse_snapshots_mask(const char *str); -- cgit 2.12.1