diff options
author | René Scharfe <l.s.r@web.de> | 2014-11-09 14:49:54 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-11-10 10:04:13 -0800 |
commit | a2bae2dce1fc2fe14894d46e01ee093b5704941a (patch) | |
tree | bdfe7e308cd3254f6edd466167c48ac4efa44cf7 /wt-status.c | |
parent | 66edfe9ddc29102fa39edd37f9aecccbaca6a013 (diff) | |
download | git-a2bae2dce1fc2fe14894d46e01ee093b5704941a.tar.gz |
use args member of struct child_processrs/env-array-in-child-process
Convert users of struct child_process to using the managed argv_array
args instead of providing their own. This shortens the code a bit and
ensures that the allocated memory is released automatically after use.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/wt-status.c b/wt-status.c index cdbc8d798a..b54eac5af6 100644 --- a/wt-status.c +++ b/wt-status.c @@ -726,7 +726,6 @@ static void wt_status_print_changed(struct wt_status *s) static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted) { struct child_process sm_summary = CHILD_PROCESS_INIT; - struct argv_array argv = ARGV_ARRAY_INIT; struct strbuf cmd_stdout = STRBUF_INIT; struct strbuf summary = STRBUF_INIT; char *summary_content; @@ -735,23 +734,21 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt argv_array_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s", s->index_file); - argv_array_push(&argv, "submodule"); - argv_array_push(&argv, "summary"); - argv_array_push(&argv, uncommitted ? "--files" : "--cached"); - argv_array_push(&argv, "--for-status"); - argv_array_push(&argv, "--summary-limit"); - argv_array_pushf(&argv, "%d", s->submodule_summary); + argv_array_push(&sm_summary.args, "submodule"); + argv_array_push(&sm_summary.args, "summary"); + argv_array_push(&sm_summary.args, uncommitted ? "--files" : "--cached"); + argv_array_push(&sm_summary.args, "--for-status"); + argv_array_push(&sm_summary.args, "--summary-limit"); + argv_array_pushf(&sm_summary.args, "%d", s->submodule_summary); if (!uncommitted) - argv_array_push(&argv, s->amend ? "HEAD^" : "HEAD"); + argv_array_push(&sm_summary.args, s->amend ? "HEAD^" : "HEAD"); - sm_summary.argv = argv.argv; sm_summary.git_cmd = 1; sm_summary.no_stdin = 1; fflush(s->fp); sm_summary.out = -1; run_command(&sm_summary); - argv_array_clear(&argv); len = strbuf_read(&cmd_stdout, sm_summary.out, 1024); |