From: Junio C Hamano <gitster@pobox•com>
To: "René Scharfe" <l.s.r@web•de>
Cc: Git Mailing List <git@vger•kernel.org>
Subject: Re: [PATCH v2] remote-testsvn: use internal argv_array of struct child_process in cmd_import()
Date: Fri, 18 Jul 2014 14:18:42 -0700 [thread overview]
Message-ID: <xmqqtx6el619.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <53C97BA4.7020503@web.de> ("René Scharfe"'s message of "Fri, 18 Jul 2014 21:55:16 +0200")
René Scharfe <l.s.r@web•de> writes:
> Use the existing argv_array member instead of providing our own. This
> way we don't have to initialize or clean it up explicitly. Because of
> that automatic cleanup, we need to keep our own reference to the
> command name instead of using .argv[0] to print the warning at the end.
>
> Signed-off-by: Rene Scharfe <l.s.r@web•de>
> ---
> The added command pointer makes the patch more complicated, but I think
> it still counts as a cleanup.
Surely. I'd move the "svnrdump" assignment to where the variable is
defined, though; we do not switch what "command" to run depending on
some computed conditions anyway.
>
> remote-testsvn.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/remote-testsvn.c b/remote-testsvn.c
> index 6be55cb..e3ad11b 100644
> --- a/remote-testsvn.c
> +++ b/remote-testsvn.c
> @@ -175,8 +175,8 @@ static int cmd_import(const char *line)
> char *note_msg;
> unsigned char head_sha1[20];
> unsigned int startrev;
> - struct argv_array svndump_argv = ARGV_ARRAY_INIT;
> struct child_process svndump_proc;
> + const char *command;
>
> if (read_ref(private_ref, head_sha1))
> startrev = 0;
> @@ -200,17 +200,17 @@ static int cmd_import(const char *line)
> if(dumpin_fd < 0)
> die_errno("Couldn't open svn dump file %s.", url);
> } else {
> + command = "svnrdump";
> memset(&svndump_proc, 0, sizeof(struct child_process));
> svndump_proc.out = -1;
> - argv_array_push(&svndump_argv, "svnrdump");
> - argv_array_push(&svndump_argv, "dump");
> - argv_array_push(&svndump_argv, url);
> - argv_array_pushf(&svndump_argv, "-r%u:HEAD", startrev);
> - svndump_proc.argv = svndump_argv.argv;
> + argv_array_push(&svndump_proc.args, command);
> + argv_array_push(&svndump_proc.args, "dump");
> + argv_array_push(&svndump_proc.args, url);
> + argv_array_pushf(&svndump_proc.args, "-r%u:HEAD", startrev);
>
> code = start_command(&svndump_proc);
> if (code)
> - die("Unable to start %s, code %d", svndump_proc.argv[0], code);
> + die("Unable to start %s, code %d", command, code);
> dumpin_fd = svndump_proc.out;
> }
> /* setup marks file import/export */
> @@ -226,8 +226,7 @@ static int cmd_import(const char *line)
> if (!dump_from_file) {
> code = finish_command(&svndump_proc);
> if (code)
> - warning("%s, returned %d", svndump_proc.argv[0], code);
> - argv_array_clear(&svndump_argv);
> + warning("%s, returned %d", command, code);
> }
>
> return 0;
next prev parent reply other threads:[~2014-07-18 21:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-18 15:20 [PATCH] remote-testsvn: use internal argv_array of struct child_process in cmd_import() René Scharfe
2014-07-18 19:10 ` Junio C Hamano
2014-07-18 19:30 ` René Scharfe
2014-07-18 19:55 ` [PATCH v2] " René Scharfe
2014-07-18 21:18 ` Junio C Hamano [this message]
2014-07-18 21:45 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqtx6el619.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=l.s.r@web$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox