From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] http: use internal argv_array of struct child_process
Date: Fri, 22 Dec 2017 09:14:02 +0100 [thread overview]
Message-ID: <504cafe3-2960-af2d-10fe-51e8ba3d2213@web.de> (raw)
Avoid a strangely magic array size (it's slightly too big) and explicit
index numbers by building the command line for index-pack using the
embedded argv_array of the child_process. The resulting code is shorter
and easier to extend.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
http.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/http.c b/http.c
index 215bebef1b..b22b4ada58 100644
--- a/http.c
+++ b/http.c
@@ -2025,7 +2025,6 @@ int finish_http_pack_request(struct http_pack_request *preq)
char *tmp_idx;
size_t len;
struct child_process ip = CHILD_PROCESS_INIT;
- const char *ip_argv[8];
close_pack_index(p);
@@ -2041,13 +2040,10 @@ int finish_http_pack_request(struct http_pack_request *preq)
die("BUG: pack tmpfile does not end in .pack.temp?");
tmp_idx = xstrfmt("%.*s.idx.temp", (int)len, preq->tmpfile);
- ip_argv[0] = "index-pack";
- ip_argv[1] = "-o";
- ip_argv[2] = tmp_idx;
- ip_argv[3] = preq->tmpfile;
- ip_argv[4] = NULL;
-
- ip.argv = ip_argv;
+ argv_array_push(&ip.args, "index-pack");
+ argv_array_push(&ip.args, "-o");
+ argv_array_push(&ip.args, tmp_idx);
+ argv_array_push(&ip.args, preq->tmpfile);
ip.git_cmd = 1;
ip.no_stdin = 1;
ip.no_stdout = 1;
--
2.15.1
next reply other threads:[~2017-12-22 8:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 8:14 René Scharfe [this message]
2017-12-22 8:59 ` [PATCH] http: use internal argv_array of struct child_process Eric Sunshine
2017-12-22 11:56 ` [PATCH v2] " René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=504cafe3-2960-af2d-10fe-51e8ba3d2213@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).