summaryrefslogtreecommitdiff
path: root/column.c
diff options
context:
space:
mode:
Diffstat (limited to 'column.c')
-rw-r--r--column.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/column.c b/column.c
index 9367ba5db5..ca878bcea7 100644
--- a/column.c
+++ b/column.c
@@ -311,8 +311,8 @@ static int parse_config(unsigned int *colopts, const char *value)
value += strspn(value, sep);
}
/*
- * Setting layout implies "always" if neither always, never
- * nor auto is specified.
+ * If none of "always", "never", and "auto" is specified, then setting
+ * layout implies "always".
*
* Current value in COL_ENABLE_MASK is disregarded. This means if
* you set column.ui = auto and pass --column=row, then "auto"
@@ -336,8 +336,9 @@ static int column_config(const char *var, const char *value,
int git_column_config(const char *var, const char *value,
const char *command, unsigned int *colopts)
{
- const char *it = skip_prefix(var, "column.");
- if (!it)
+ const char *it;
+
+ if (!skip_prefix(var, "column.", &it))
return 0;
if (!strcmp(it, "ui"))
@@ -370,46 +371,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);