Commit _subject_ filter, everywhere

Bjørn Forsman bjorn.forsman at
Sat Dec 2 15:44:15 CET 2017

Hi John,

On 2 December 2017 at 13:49, John Keeping <john at> wrote:
> After I wrote that I realised that for the existing commit-filter we
> escape the content before writing to the filter.  So it might be
> reasonable to pass the whole <a></a> tag through the filter.
> That would make it easy for the filter to put extra content either
> before or after the commit subject.  It also makes the filter
> integration much simpler, for example in ui-log.c:
> -- >8 --
> diff --git a/ui-log.c b/ui-log.c
> index 2d2bb31..f2a7852 100644
> --- a/ui-log.c
> +++ b/ui-log.c
> @@ -234,8 +234,11 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
>                         strcpy(info->subject + i, wrap_symbol);
>                 }
>         }
> +       cgit_open_filter(ctx.repo->subject_filter,
> +                        oid_to_hex(&commit->object.oid));
>         cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
>                          oid_to_hex(&commit->object.oid), ctx.qry.vpath);
> +       cgit_close_filter(ctx.repo->subject_filter);
>         show_commit_decorations(commit);
>         html("</td><td>");
>         cgit_open_filter(ctx.repo->email_filter, info->author_email, "log");
> -- 8< --

I applied that patch, with s/subject_filter/commit_filter/, and
updated my commit-filter to output a small SVG (borrowed from in front of the commit message.

Here is the result:

I think it's looking good!

On small annoyance though is that the CI status element, when loaded,
causes the commit messages to move sideways. Ideally, the CI status
(or whatever the user chose to attach to the commit) would not cause
the layout to move (unless it's very big). I guess that's a
conflicting goal between having a "commit prefix" and a dedicated
column for this extra info. Another alternative is _appending_ the
element, which a filter program has the ability to do. Then the layout
would be stable, but the CI status elements would not align nicely in
a column anymore. Hmm... :-)

> We normally use arguments for this, which is all handled via the
> cgit_open_filter() function.
> I expect Lua filters may be preferred for this use case to avoid forking
> 50 child processes when displaying the log view.

Good point.

Best regards,
Bjørn Forsman

More information about the CGit mailing list