diff options
author | René Scharfe <l.s.r@web.de> | 2014-06-29 22:47:00 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-29 23:41:02 -0700 |
commit | 85dd6bf4911dc6d08857c234fe3c135abeed2c44 (patch) | |
tree | 6d012dbc614920a51ea20d6b3bc2b072ba290410 /wt-status.c | |
parent | 341e7e8eda3dbeb6867f4f8f45b671201b807de5 (diff) | |
download | git-85dd6bf4911dc6d08857c234fe3c135abeed2c44.tar.gz |
wt-status: use argv_array for environment
Instead of using a PATH_MAX buffer, use argv_array for constructing the
environment for git submodule summary. This simplifies the code a bit
and removes the arbitrary length limit.
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 | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/wt-status.c b/wt-status.c index 86fec8986f..ed5db49502 100644 --- a/wt-status.c +++ b/wt-status.c @@ -735,8 +735,7 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt { struct child_process sm_summary; char summary_limit[64]; - char index[PATH_MAX]; - const char *env[] = { NULL, NULL }; + struct argv_array env = ARGV_ARRAY_INIT; struct argv_array argv = ARGV_ARRAY_INIT; struct strbuf cmd_stdout = STRBUF_INIT; struct strbuf summary = STRBUF_INIT; @@ -744,9 +743,8 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt size_t len; sprintf(summary_limit, "%d", s->submodule_summary); - snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file); + argv_array_pushf(&env, "GIT_INDEX_FILE=%s", s->index_file); - env[0] = index; argv_array_push(&argv, "submodule"); argv_array_push(&argv, "summary"); argv_array_push(&argv, uncommitted ? "--files" : "--cached"); @@ -758,13 +756,14 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt memset(&sm_summary, 0, sizeof(sm_summary)); sm_summary.argv = argv.argv; - sm_summary.env = env; + sm_summary.env = env.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(&env); argv_array_clear(&argv); len = strbuf_read(&cmd_stdout, sm_summary.out, 1024); |