From mboxrd@z Thu Jan 1 00:00:00 1970 From: jamie.couture at gmail.com (Jamie Couture) Date: Wed, 30 Jul 2014 14:53:21 -0400 Subject: [PATCH] ui-tree.c: check source filter if set globally In-Reply-To: <87a97t89to.fsf@columbia.edu> References: <87a97t89to.fsf@columbia.edu> Message-ID: <1406746401-24187-1-git-send-email-jamie.couture@gmail.com> When parsing cgitrc users that place 'source-filter' setting after 'scan-path' find their source filter is never run. scan-path=/home/git/repositories source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.sh ui-tree.c will print out our repository objects, but will only consider ctx.repo->source_filter struct and not checking ctx.cfg.source_filter The value would have been set in shared.c, via cgit_add_repo() but this isn't the case when using scan-path, because we have not yet processed the source-filter line in our cgitrc, and thus the source_filter struct will not be initialized. Checking the global configuration in ui-tree.c is necessary to avoid an issue where users declare the source filter after scan-path. Signed-off-by: Jamie Couture --- ui-tree.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ui-tree.c b/ui-tree.c index e4c3d22..f52f15c 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -22,6 +22,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) { unsigned long lineno, idx; const char *numberfmt = "%1$d\n"; + struct cgit_filter *source_filter = NULL; html("\n"); @@ -45,11 +46,17 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) } if (ctx.repo->source_filter) { + source_filter = ctx.repo->source_filter; + } else if (ctx.cfg.source_filter) { + source_filter = ctx.cfg.source_filter; + } + + if (source_filter) { char *filter_arg = xstrdup(name); html("
");
-		cgit_open_filter(ctx.repo->source_filter, filter_arg);
+		cgit_open_filter(source_filter, filter_arg);
 		html_raw(buf, size);
-		cgit_close_filter(ctx.repo->source_filter);
+		cgit_close_filter(source_filter);
 		free(filter_arg);
 		html("
\n"); return; -- 1.9.1.377.g96e67c8