public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Felipe Contreras <felipe.contreras@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH 4/5] transport-helper: trivial cleanup
Date: Mon, 14 Apr 2014 14:14:30 -0700	[thread overview]
Message-ID: <xmqqha5vmx55.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: 1397334812-12215-5-git-send-email-felipe.contreras@gmail.com

Felipe Contreras <felipe.contreras@gmail•com> writes:

> It's simpler to store the file names directly, and form the fast-export
> arguments only when needed, and re-use the same strbuf with a format.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail•com>
> ---
>  transport-helper.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/transport-helper.c b/transport-helper.c
> index b068ea5..2747f98 100644
> --- a/transport-helper.c
> +++ b/transport-helper.c
> @@ -195,15 +195,9 @@ static struct child_process *get_helper(struct transport *transport)
>  		} else if (!strcmp(capname, "signed-tags")) {
>  			data->signed_tags = 1;
>  		} else if (starts_with(capname, "export-marks ")) {
> -			struct strbuf arg = STRBUF_INIT;
> -			strbuf_addstr(&arg, "--export-marks=");
> -			strbuf_addstr(&arg, capname + strlen("export-marks "));
> -			data->export_marks = strbuf_detach(&arg, NULL);
> +			data->export_marks = xstrdup(capname + strlen("export-marks "));
>  		} else if (starts_with(capname, "import-marks")) {
> -			struct strbuf arg = STRBUF_INIT;
> -			strbuf_addstr(&arg, "--import-marks=");
> -			strbuf_addstr(&arg, capname + strlen("import-marks "));
> -			data->import_marks = strbuf_detach(&arg, NULL);
> +			data->import_marks = xstrdup(capname + strlen("import-marks "));
>  		} else if (starts_with(capname, "no-private-update")) {
>  			data->no_private_update = 1;
>  		} else if (mandatory) {
> @@ -429,6 +423,7 @@ static int get_exporter(struct transport *transport,
>  	struct child_process *helper = get_helper(transport);
>  	int argc = 0, i;
>  	memset(fastexport, 0, sizeof(*fastexport));
> +	struct strbuf tmp = STRBUF_INIT;

Will fix up decl-after-stmt while queuing.

>  
>  	/* we need to duplicate helper->in because we want to use it after
>  	 * fastexport is done with it. */
> @@ -438,10 +433,14 @@ static int get_exporter(struct transport *transport,
>  	fastexport->argv[argc++] = "--use-done-feature";
>  	fastexport->argv[argc++] = data->signed_tags ?
>  		"--signed-tags=verbatim" : "--signed-tags=warn-strip";
> -	if (data->export_marks)
> -		fastexport->argv[argc++] = data->export_marks;
> -	if (data->import_marks)
> -		fastexport->argv[argc++] = data->import_marks;
> +	if (data->export_marks) {
> +		strbuf_addf(&tmp, "--export-marks=%s", data->export_marks);
> +		fastexport->argv[argc++] = strbuf_detach(&tmp, NULL);
> +	}
> +	if (data->import_marks) {
> +		strbuf_addf(&tmp, "--import-marks=%s", data->import_marks);
> +		fastexport->argv[argc++] = strbuf_detach(&tmp, NULL);
> +	}
>  
>  	for (i = 0; i < revlist_args->nr; i++)
>  		fastexport->argv[argc++] = revlist_args->items[i].string;

  reply	other threads:[~2014-04-14 21:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-12 20:33 [PATCH 0/5] transport-helper: serious crash fix Felipe Contreras
2014-04-12 20:33 ` [PATCH 1/5] transport-helper: remove barely used xchgline() Felipe Contreras
2014-04-12 20:33 ` [PATCH 2/5] remote-helpers: make recvline return an error Felipe Contreras
2014-04-12 20:33 ` [PATCH 3/5] transport-helper: propagate recvline() error pushing Felipe Contreras
2014-04-12 20:33 ` [PATCH 4/5] transport-helper: trivial cleanup Felipe Contreras
2014-04-14 21:14   ` Junio C Hamano [this message]
2014-04-12 20:33 ` [PATCH 5/5] transport-helper: fix sync issue on crashes Felipe Contreras
2014-04-14 21:25   ` Junio C Hamano
2014-04-15 21:28 ` [PATCH 0/5] transport-helper: serious crash fix Junio C Hamano
2014-04-19  7:00 ` [PATCH 0/5] fc/transport-helper-sync-error-fix rebased Junio C Hamano
2014-04-19  7:00   ` [PATCH 1/5] transport-helper: remove barely used xchgline() Junio C Hamano
2014-04-19  7:00   ` [PATCH 2/5] remote-helpers: make recvline return an error Junio C Hamano
2014-04-19  7:00   ` [PATCH 3/5] transport-helper: propagate recvline() error pushing Junio C Hamano
2014-04-19  7:00   ` [PATCH 4/5] transport-helper: trivial cleanup Junio C Hamano
2014-04-19  7:00   ` [PATCH 5/5] transport-helper: fix sync issue on crashes Junio C Hamano
2014-04-20 18:36   ` [PATCH 0/5] fc/transport-helper-sync-error-fix rebased Felipe Contreras
2014-04-20 21:10     ` Junio C Hamano
2014-04-20 21:12       ` Felipe Contreras
2014-04-20 21:52         ` Junio C Hamano
2014-04-20 21:54           ` Felipe Contreras

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=xmqqha5vmx55.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=felipe.contreras@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    /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