]> granicus.if.org Git - cgit/commitdiff
Merge branch 'fh/filter-api'
authorLars Hjemli <hjemli@gmail.com>
Mon, 23 May 2011 21:28:38 +0000 (23:28 +0200)
committerLars Hjemli <hjemli@gmail.com>
Mon, 23 May 2011 21:28:38 +0000 (23:28 +0200)
Conflicts:
cgit.c

1  2 
cgit.c
cgit.h
cgitrc.5.txt
shared.c
ui-repolist.c
ui-tree.c

diff --cc cgit.c
index eb964ac082f3be22305915040269c57715e0a88d,5d6e4886dd2fe2b31df0fc0124f0e53d9115ce9d..6be3754d47d1c75300189ebab68e0a1c6488a139
--- 1/cgit.c
--- 2/cgit.c
+++ b/cgit.c
@@@ -26,20 -26,31 +26,33 @@@ void add_mimetype(const char *name, con
        item->util = xstrdup(value);
  }
  
- struct cgit_filter *new_filter(const char *cmd, int extra_args)
+ struct cgit_filter *new_filter(const char *cmd, filter_type filtertype)
  {
        struct cgit_filter *f;
 +      int args_size = 0;
+       int extra_args;
  
        if (!cmd || !cmd[0])
                return NULL;
  
+       switch (filtertype) {
+               case SOURCE:
+                       extra_args = 1;
+                       break;
+               case ABOUT:
+               case COMMIT:
+               default:
+                       extra_args = 0;
+                       break;
+       }
        f = xmalloc(sizeof(struct cgit_filter));
        f->cmd = xstrdup(cmd);
 -      f->argv = xmalloc((2 + extra_args) * sizeof(char *));
 +      args_size = (2 + extra_args) * sizeof(char *);
 +      f->argv = xmalloc(args_size);
 +      memset(f->argv, 0, args_size);
        f->argv[0] = f->cmd;
 -      f->argv[1] = NULL;
        return f;
  }
  
diff --cc cgit.h
Simple merge
diff --cc cgitrc.5.txt
Simple merge
diff --cc shared.c
Simple merge
diff --cc ui-repolist.c
Simple merge
diff --cc ui-tree.c
index 442b6be53d2c6ba6f7f4c17cd53d12da198c6f5d,835c166317093ed0d6c1eee7b35a3c8b3d8a5b18..2d8d2f3b83738fb007228f6f84e78dbe881d7f39
+++ b/ui-tree.c
@@@ -45,11 -45,9 +45,11 @@@ static void print_text_buffer(const cha
        if (ctx.repo->source_filter) {
                html("<td class='lines'><pre><code>");
                ctx.repo->source_filter->argv[1] = xstrdup(name);
-               cgit_open_filter(ctx.repo->source_filter);
+               cgit_open_filter(ctx.repo->source_filter, ctx.repo);
                html_raw(buf, size);
                cgit_close_filter(ctx.repo->source_filter);
 +              free(ctx.repo->source_filter->argv[1]);
 +              ctx.repo->source_filter->argv[1] = NULL;
                html("</code></pre></td></tr></table>\n");
                return;
        }