Merge branch 'mc/doc-submodule-sync-recurse'
[gitweb.git] / column.c
index 8d1ce88d1493cf18436b03f843c6d90190d47bb2..1a468debb4abdda3cbb90fcc4972b3d40da6f2ed 100644 (file)
--- a/column.c
+++ b/column.c
@@ -370,46 +370,29 @@ static struct child_process column_process;
 
 int run_column_filter(int colopts, const struct column_options *opts)
 {
-       const char *av[10];
-       int ret, ac = 0;
-       struct strbuf sb_colopt  = STRBUF_INIT;
-       struct strbuf sb_width   = STRBUF_INIT;
-       struct strbuf sb_padding = STRBUF_INIT;
+       struct argv_array *argv;
 
        if (fd_out != -1)
                return -1;
 
-       av[ac++] = "column";
-       strbuf_addf(&sb_colopt, "--raw-mode=%d", colopts);
-       av[ac++] = sb_colopt.buf;
-       if (opts && opts->width) {
-               strbuf_addf(&sb_width, "--width=%d", opts->width);
-               av[ac++] = sb_width.buf;
-       }
-       if (opts && opts->indent) {
-               av[ac++] = "--indent";
-               av[ac++] = opts->indent;
-       }
-       if (opts && opts->padding) {
-               strbuf_addf(&sb_padding, "--padding=%d", opts->padding);
-               av[ac++] = sb_padding.buf;
-       }
-       av[ac] = NULL;
+       memset(&column_process, 0, sizeof(column_process));
+       argv = &column_process.args;
+
+       argv_array_push(argv, "column");
+       argv_array_pushf(argv, "--raw-mode=%d", colopts);
+       if (opts && opts->width)
+               argv_array_pushf(argv, "--width=%d", opts->width);
+       if (opts && opts->indent)
+               argv_array_pushf(argv, "--indent=%s", opts->indent);
+       if (opts && opts->padding)
+               argv_array_pushf(argv, "--padding=%d", opts->padding);
 
        fflush(stdout);
-       memset(&column_process, 0, sizeof(column_process));
        column_process.in = -1;
        column_process.out = dup(1);
        column_process.git_cmd = 1;
-       column_process.argv = av;
-
-       ret = start_command(&column_process);
-
-       strbuf_release(&sb_colopt);
-       strbuf_release(&sb_width);
-       strbuf_release(&sb_padding);
 
-       if (ret)
+       if (start_command(&column_process))
                return -2;
 
        fd_out = dup(1);