git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/5] transport-helper: trivial cleanup

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 14, 2014, 21:14 UTC
Message-ID
<xmqqha5vmx55.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1397334812-12215-5-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 35 quoted lines
> 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.
Show 22 quoted lines
>  
>  	/* 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;
Previous: Felipe ContrerasNext: Felipe Contreras
Message 6 of 20 in “transport-helper: serious crash fix”
  1. 0/5 transport-helper: serious crash fixFelipe Contreras, Apr 12, 2014
  2. 1/5 transport-helper: remove barely used xchgline()Felipe Contreras, Apr 12, 2014
  3. 2/5 remote-helpers: make recvline return an errorFelipe Contreras, Apr 12, 2014
  4. 3/5 transport-helper: propagate recvline() error pushingFelipe Contreras, Apr 12, 2014
  5. 4/5 transport-helper: trivial cleanupFelipe Contreras, Apr 12, 2014
  6. Junio C HamanoApr 14, 2014
  7. 5/5 transport-helper: fix sync issue on crashesFelipe Contreras, Apr 12, 2014
  8. Junio C HamanoApr 14, 2014
  9. Junio C HamanoApr 15, 2014
  10. 0/5 fc/transport-helper-sync-error-fix rebasedJunio C Hamano, Apr 19, 2014
  11. 1/5 transport-helper: remove barely used xchgline()Junio C Hamano, Apr 19, 2014
  12. 2/5 remote-helpers: make recvline return an errorJunio C Hamano, Apr 19, 2014
  13. 3/5 transport-helper: propagate recvline() error pushingJunio C Hamano, Apr 19, 2014
  14. 4/5 transport-helper: trivial cleanupJunio C Hamano, Apr 19, 2014
  15. 5/5 transport-helper: fix sync issue on crashesJunio C Hamano, Apr 19, 2014
  16. Felipe ContrerasApr 20, 2014
  17. Junio C HamanoApr 20, 2014
  18. Felipe ContrerasApr 20, 2014
  19. Junio C HamanoApr 20, 2014
  20. Felipe ContrerasApr 20, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.