aboutsummaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-08-19 21:09:35 +0200
committerJunio C Hamano <gitster@pobox.com>2014-08-20 09:53:37 -0700
commitd3180279322c7450a47decf8833de47f444ca93f (patch)
tree6b15045aef08b51a0831ee75bb67fd0beddc0d0c /transport.c
parent6c4ab27f2378ce67940b4496365043119d7ffff2 (diff)
downloadgit-d3180279322c7450a47decf8833de47f444ca93f.tar.gz
git-d3180279322c7450a47decf8833de47f444ca93f.tar.xz
run-command: introduce CHILD_PROCESS_INIT
Most struct child_process variables are cleared using memset first after declaration. Provide a macro, CHILD_PROCESS_INIT, that can be used to initialize them statically instead. That's shorter, doesn't require a function call and is slightly more readable (especially given that we already have STRBUF_INIT, ARGV_ARRAY_INIT etc.). Helped-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/transport.c b/transport.c
index 662421bb5..7388bb87d 100644
--- a/transport.c
+++ b/transport.c
@@ -201,7 +201,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
{
struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
struct ref dummy = {NULL}, *tail = &dummy;
- struct child_process rsync;
+ struct child_process rsync = CHILD_PROCESS_INIT;
const char *args[5];
int temp_dir_len;
@@ -218,7 +218,6 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
strbuf_addstr(&buf, rsync_url(transport->url));
strbuf_addstr(&buf, "/refs");
- memset(&rsync, 0, sizeof(rsync));
rsync.argv = args;
rsync.stdout_to_stderr = 1;
args[0] = "rsync";
@@ -263,9 +262,8 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
static int fetch_objs_via_rsync(struct transport *transport,
int nr_objs, struct ref **to_fetch)
{
- struct child_process rsync;
+ struct child_process rsync = CHILD_PROCESS_INIT;
- memset(&rsync, 0, sizeof(rsync));
rsync.stdout_to_stderr = 1;
argv_array_push(&rsync.args, "rsync");
argv_array_push(&rsync.args, (transport->verbose > 1) ? "-rv" : "-r");
@@ -327,7 +325,7 @@ static int rsync_transport_push(struct transport *transport,
{
struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
int result = 0, i;
- struct child_process rsync;
+ struct child_process rsync = CHILD_PROCESS_INIT;
const char *args[10];
if (flags & TRANSPORT_PUSH_MIRROR)
@@ -338,7 +336,6 @@ static int rsync_transport_push(struct transport *transport,
strbuf_addstr(&buf, rsync_url(transport->url));
strbuf_addch(&buf, '/');
- memset(&rsync, 0, sizeof(rsync));
rsync.argv = args;
rsync.stdout_to_stderr = 1;
i = 0;
@@ -1056,7 +1053,7 @@ static int run_pre_push_hook(struct transport *transport,
{
int ret = 0, x;
struct ref *r;
- struct child_process proc;
+ struct child_process proc = CHILD_PROCESS_INIT;
struct strbuf buf;
const char *argv[4];
@@ -1067,7 +1064,6 @@ static int run_pre_push_hook(struct transport *transport,
argv[2] = transport->url;
argv[3] = NULL;
- memset(&proc, 0, sizeof(proc));
proc.argv = argv;
proc.in = -1;