RFE: .so filters

John Keeping john at keeping.me.uk
Fri Jan 10 21:36:52 CET 2014

On Fri, Jan 10, 2014 at 09:25:18PM +0100, Florian Pritz wrote:
> On 10.01.2014 21:11, John Keeping wrote:
> > Forking and using Lua in the child is an interesting idea.
> > 
> > I need to investigate how Lua generally deals with I/O, but it feels
> > like it will be simpler to use a simple function interface than deal
> > with slurping in the input in Lua.
> Looks rather easy to slurp stdin (from http://www.lua.org/pil/21.1.html):

Interesting.  But I think it will be simpler from both side if the
interface is just a function call:

    function filter(value)
        return value .. " some trailing data"

The change on the CGit side is then quite easy, we just change the
switchable value in html.c from htmlfd to html_out_fn which has the same
signature as html_raw (which is the default implementation).  Then we
can collect output in a strbuf until it's time to call the function.

The only thing I'm not sure about is how the specification of the filter
function works, given that I don't think we can call a complete Lua
script as a function.  (I'm also assuming that the Lua script will be in
an external file and not stored inline in the CGit config).

More information about the CGit mailing list