@matheusbsbs / matheus-bagliano / commits / a807328979
Fork 0

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

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>

Tom Preston-Werner committed Nov 1, 2008 at 11:44 UTC a80732897931c737c01d04289dd1512bd12a4b04
1 file changed +3
connect.c
+3
@@ -70,6 +70,9 @@ struct ref **get_remote_heads(int in, struct ref **list,
70 if (buffer[len-1] == '\n')
71 buffer[--len] = 0;
72
73 + if (len > 4 && !prefixcmp(buffer, "ERR "))
74 + die("remote error: %s", buffer + 4);
75 +
76 if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
77 die("protocol error: expected sha/ref, got '%s'", buffer);
78 name = buffer + 41;