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

http-fetch: nicer warning for a server with unreliable 404 status

When a repository otherwise properly prepared is served by a dumb HTTP server that sends "No such page" output with 200 status for human consumption to a request for a page that does not exist, the users will get an alarming "File X corrupt" error message. Hint that they might be dealing with such a server at the end and suggest running fsck-objects to check if the result is OK (the pack-fallback code does the right thing in this case so unless a loose object file was actually corrupt the result should check OK). Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Mar 20, 2006 at 14:07 UTC bb52807916598301e670963e6cc5f1f5cdca3ad7
1 file changed +8
http-fetch.c
+8
@@ -8,6 +8,7 @@
8 #define RANGE_HEADER_SIZE 30
9
10 static int got_alternates = -1;
11 +static int corrupt_object_found = 0;
12
13 static struct curl_slist *no_pragma_header;
14
@@ -834,6 +835,7 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
835 obj_req->errorstr, obj_req->curl_result,
836 obj_req->http_code, hex);
837 } else if (obj_req->zret != Z_STREAM_END) {
838 + corrupt_object_found++;
839 ret = error("File %s (%s) corrupt", hex, obj_req->url);
840 } else if (memcmp(obj_req->sha1, obj_req->real_sha1, 20)) {
841 ret = error("File %s has bad hash", hex);
@@ -993,5 +995,11 @@ int main(int argc, char **argv)
995
996 http_cleanup();
997
998 + if (corrupt_object_found) {
999 + fprintf(stderr,
1000 +"Some loose object were found to be corrupt, but they might be just\n"
1001 +"a false '404 Not Found' error message sent with incorrect HTTP\n"
1002 +"status code. Suggest running git fsck-objects.\n");
1003 + }
1004 return rc;
1005 }