* [PATCH 1/2] wt-status: use argv_array for environment
@ 2014-06-29 20:47 René Scharfe
2014-06-29 20:55 ` [PATCH 2/2] wt-status: simplify building of summary limit argument René Scharfe
0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2014-06-29 20:47 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Jens Lehmann, Matthieu Moy
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>
---
wt-status.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 318a191..2c0bff8 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);
--
2.0.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] wt-status: simplify building of summary limit argument
2014-06-29 20:47 [PATCH 1/2] wt-status: use argv_array for environment René Scharfe
@ 2014-06-29 20:55 ` René Scharfe
2014-07-01 8:44 ` Matthieu Moy
0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2014-06-29 20:55 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Jens Lehmann, Matthieu Moy
Use argv_array_pushf for building the number string for the option
--summary-limit directly instead of using an intermediate buffer.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
wt-status.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 2c0bff8..882cfe9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -734,7 +734,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;
- char summary_limit[64];
struct argv_array env = ARGV_ARRAY_INIT;
struct argv_array argv = ARGV_ARRAY_INIT;
struct strbuf cmd_stdout = STRBUF_INIT;
@@ -742,7 +741,6 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
char *summary_content;
size_t len;
- sprintf(summary_limit, "%d", s->submodule_summary);
argv_array_pushf(&env, "GIT_INDEX_FILE=%s", s->index_file);
argv_array_push(&argv, "submodule");
@@ -750,7 +748,7 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
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");
--
2.0.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] wt-status: simplify building of summary limit argument
2014-06-29 20:55 ` [PATCH 2/2] wt-status: simplify building of summary limit argument René Scharfe
@ 2014-07-01 8:44 ` Matthieu Moy
0 siblings, 0 replies; 3+ messages in thread
From: Matthieu Moy @ 2014-07-01 8:44 UTC (permalink / raw)
To: René Scharfe; +Cc: Git Mailing List, Junio C Hamano, Jens Lehmann
René Scharfe <l.s.r@web.de> writes:
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> wt-status.c | 4 +---
Both patches sound straightforward and good to me.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-01 8:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-29 20:47 [PATCH 1/2] wt-status: use argv_array for environment René Scharfe
2014-06-29 20:55 ` [PATCH 2/2] wt-status: simplify building of summary limit argument René Scharfe
2014-07-01 8:44 ` Matthieu Moy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).