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

Re: [PATCH] connect.c: add a way for git-daemon to pass an error back to client

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 1, 2008, 05:39 UTC
Message-ID
<7vy7043sy9.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<b97024a40810311859t2e5a6102u31ad4480e7c75c03@mail.gmail.com>
"Tom Preston-Werner" <tom@github.com> writes:
> Example
>
> S: ERR No matching repository.
> C: fatal: remote error: No matching repository.
I like what this tries to do.

I briefly wondered if this should be restricted to the very first message from the other end, but I think it is not necessary. If the remote throws a few valid looking "SHA-1 SP refname" lines and then said "ERR" (which cannot be the beginning of a valid SHA-1), we can safely and unambiguously declare that this is an error message from the remote end.

Show 9 quoted lines
> diff --git a/connect.c b/connect.c
> index 0c50d0a..3af91d6 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -70,6 +70,9 @@ struct ref **get_remote_heads(int in, struct ref **list,
>  		if (buffer[len-1] == '\n')
>  			buffer[--len] = 0;
>
> +		if (len > 4 && !memcmp("ERR", buffer, 3))

Would matching 4 bytes "ERR " here an improvement? You are expecting buffer+4 is where the message begins in die() anyway, and otherwise you would show the message without "N" if you got "ERRNo matching repo".

> +			die("remote error: %s", buffer + 4);
> +

It was very considerate that you did not say "server error" in the error message. This code is shared between both the fetch side and the push side.

Previous: Andreas EricssonNext: Tom Preston-Werner
Message 10 of 13 in “connect.c: add a way for git-daemon to pass an error back to client”
  1. connect.c: add a way for git-daemon to pass an error back to clientTom Preston-Werner, Nov 1, 2008
  2. Johannes SchindelinNov 1, 2008
  3. Tom Preston-WernerNov 1, 2008
  4. Nicolas PitreNov 1, 2008
  5. Johannes SchindelinNov 1, 2008
  6. Tom Preston-WernerNov 1, 2008
  7. Andreas EricssonNov 1, 2008
  8. Alex RiesenNov 1, 2008
  9. Andreas EricssonNov 1, 2008
  10. Junio C HamanoNov 1, 2008
  11. Tom Preston-WernerNov 1, 2008
  12. Shawn O. PearceNov 1, 2008
  13. Junio C HamanoNov 1, 2008

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.