{"thread":{"id":"16121","subject":"[PATCH v2] connect.c: add a way for git-daemon to pass an error back to client","startedAt":"2008-11-01T18:44:45Z","lastAt":"2008-11-01T18:44:45Z","messageCount":1,"participants":["Tom Preston-Werner"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"94575","messageId":"b97024a40811011144s7f4bca47w1cc92b0975cecbc5@mail.gmail.com","threadId":"16121","inReplyTo":null,"subject":"[PATCH v2] connect.c: add a way for git-daemon to pass an error back to client","fromName":"Tom Preston-Werner","fromEmail":"tom@github.com","sentAt":"2008-11-01T18:44:45Z","receivedAt":"2008-11-01T18:44:45Z","isPatch":true,"sender":{"key":"tom@github.com","avatar":"https://gravatar.com/avatar/e38396c4b4d7977fac079a61a1b22c7eca553a9aac50efb1862daac22c65fc58?d=mp&s=160"},"body":"The current behavior of git-daemon is to simply close the connection on\nany error condition. This leaves the client without any information as\nto the cause of the failed fetch/push/etc.\n\nThis patch allows get_remote_heads to accept a line prefixed with \"ERR\"\nthat it can display to the user in an informative fashion. Once clients\ncan understand this ERR line, git-daemon can be made to properly report\n\"repository not found\", \"permission denied\", or other errors.\n\nExample\n\nS: ERR No matching repository.\nC: fatal: remote error: No matching repository.\n\nSigned-off-by: Tom Preston-Werner <tom@github.com>\n---\nUse prefixcmp instead of memcmp and test for \"ERR \" instead of \"ERR\"\n\n connect.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/connect.c b/connect.c\nindex 0c50d0a..584e04c 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -70,6 +70,9 @@ struct ref **get_remote_heads(int in, struct ref **list,\n \t\tif (buffer[len-1] == '\\n')\n \t\t\tbuffer[--len] = 0;\n\n+\t\tif (len > 4 && !prefixcmp(buffer, \"ERR \"))\n+\t\t\tdie(\"remote error: %s\", buffer + 4);\n+\n \t\tif (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')\n \t\t\tdie(\"protocol error: expected sha/ref, got '%s'\", buffer);\n \t\tname = buffer + 41;\n-- \n1.6.0.2\n"}]}