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

Re: [PATCH] remote-curl: Fix push status report when all branches fail

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 19, 2012, 22:57 UTC
Message-ID
<7vzkdjgv1i.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1327011899-18883-1-git-send-email-spearce@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 8 quoted lines
> Always print a blank line after the send-pack process terminates,
> ensuring the helper status report (if it was output) will be
> correctly parsed by the calling transport-helper.c. This ensures
> the helper doesn't abort before the status report can be shown to
> the user.
>
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ---
Anybody wants to add a simple test for this failure mode?
Show 29 quoted lines
>  remote-curl.c |    9 ++++-----
>  1 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/remote-curl.c b/remote-curl.c
> index 48c20b8..d6054e2 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -805,7 +805,7 @@ static int push(int nr_spec, char **specs)
>  static void parse_push(struct strbuf *buf)
>  {
>  	char **specs = NULL;
> -	int alloc_spec = 0, nr_spec = 0, i;
> +	int alloc_spec = 0, nr_spec = 0, i, ret;
>  
>  	do {
>  		if (!prefixcmp(buf->buf, "push ")) {
> @@ -822,12 +822,11 @@ static void parse_push(struct strbuf *buf)
>  			break;
>  	} while (1);
>  
> -	if (push(nr_spec, specs))
> +	ret = push(nr_spec, specs);
> +	xwrite(1, "\n", 1);
> +	if (ret)
>  		exit(128); /* error already reported */
>  
> -	printf("\n");
> -	fflush(stdout);
> -

This is not a fault of this patch, but could we fix this ugly mixture of xwrite() and printf() in the same program? I can see that the loop in the main() function carefully tries to call fflush(stdout) to make sure that nothing is pending after processing a single command so using xwrite() may not cause any harm here, but the thing is that you do not check the error return from this xwrite(), so use of it is not giving us any potential benefit of being able to detect I/O errors in a finer grained manner, i.e. it is no better than the printf("\n"); fflush(stdout); sequence it replaces.

Thanks.
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 2 of 14 in “remote-curl: Fix push status report when all branches fail”
  1. remote-curl: Fix push status report when all branches failShawn O. Pearce, Jan 19, 2012
  2. Junio C HamanoJan 19, 2012
  3. remote-curl: Fix push status report when all branches failShawn O. Pearce, Jan 20, 2012
  4. Junio C HamanoJan 20, 2012
  5. Junio C HamanoJan 20, 2012
  6. Shawn PearceJan 20, 2012
  7. Thomas RastJan 20, 2012
  8. remote-curl: Fix push status report when all branches failShawn O. Pearce, Jan 20, 2012
  9. Junio C HamanoJan 20, 2012
  10. Jeff KingFeb 22, 2012
  11. Shawn PearceFeb 22, 2012
  12. Jeff KingFeb 22, 2012
  13. Jeff KingFeb 23, 2012
  14. Junio C HamanoFeb 23, 2012

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.