Skip to content

Commit

Permalink
connect.c: add a way for git-daemon to pass an error back to client
Browse files Browse the repository at this point in the history
The current behavior of git-daemon is to simply close the connection on
any error condition. This leaves the client without any information as
to the cause of the failed fetch/push/etc.

This patch allows get_remote_heads to accept a line prefixed with "ERR"
that it can display to the user in an informative fashion. Once clients
can understand this ERR line, git-daemon can be made to properly report
"repository not found", "permission denied", or other errors.

Example

S: ERR No matching repository.
C: fatal: remote error: No matching repository.

Signed-off-by: Tom Preston-Werner <tom@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Tom Preston-Werner authored and Junio C Hamano committed Nov 2, 2008
1 parent a240de1 commit a807328
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 && !prefixcmp(buffer, "ERR "))
die("remote error: %s", buffer + 4);

if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
die("protocol error: expected sha/ref, got '%s'", buffer);
name = buffer + 41;
Expand Down

0 comments on commit a807328

Please sign in to comment.