diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-07-10 22:27:50 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-10 22:27:50 +0400 |
commit | e7cdec622afeae0869140e72a1c45392e672465e (patch) | |
tree | 51e3fff3e209c731e8028e1f871fb0f7ba24d562 | |
parent | 11def366e5a126f9b86f3baf32b9798cef712668 (diff) | |
parent | 10761eb6812bfe46c50360685916ae14859a2b85 (diff) |
Merge branch 'rs/status-code-clean-up'
* rs/status-code-clean-up:
wt-status: simplify building of summary limit argument
wt-status: use argv_array for environment
-rw-r--r-- | wt-status.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/wt-status.c b/wt-status.c index 318a191238..882cfe9fb0 100644 --- a/wt-status.c +++ b/wt-status.c @@ -734,37 +734,34 @@ 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; - 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; char *summary_content; 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"); argv_array_push(&argv, "--for-status"); argv_array_push(&argv, "--summary-limit"); - argv_array_push(&argv, summary_limit); + argv_array_pushf(&argv, "%d", s->submodule_summary); if (!uncommitted) argv_array_push(&argv, s->amend ? "HEAD^" : "HEAD"); 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); |