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

Make http-push smarter about creating remote dirs

Remember object directories known to exist in the remote repo and don't bother trying to create them. Signed-off-by: Nick Hengeveld <nickh@reactrix.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Nick Hengeveld committed Nov 7, 2005 at 11:39 UTC 0dd276b8713a484496a2ef694b6c72b1ddbef08b
1 file changed +9 -1
http-push.c
+9 -1
@@ -47,6 +47,7 @@ static int active_requests = 0;
47 static int data_received;
48 static int pushing = 0;
49 static int aborted = 0;
50 +static char remote_dir_exists[256];
51
52 #ifdef USE_CURL_MULTI
53 static int max_requests = -1;
@@ -650,6 +651,7 @@ static void finish_request(struct transfer_request *request)
651 if (request->http_code == 404) {
652 request->state = NEED_PUSH;
653 } else if (request->curl_result == CURLE_OK) {
654 + remote_dir_exists[request->sha1[0]] = 1;
655 request->state = COMPLETE;
656 } else {
657 fprintf(stderr, "HEAD %s failed, aborting (%d/%ld)\n",
@@ -661,6 +663,7 @@ static void finish_request(struct transfer_request *request)
663 } else if (request->state == RUN_MKCOL) {
664 if (request->curl_result == CURLE_OK ||
665 request->http_code == 405) {
666 + remote_dir_exists[request->sha1[0]] = 1;
667 start_put(request);
668 } else {
669 fprintf(stderr, "MKCOL %s failed, aborting (%d/%ld)\n",
@@ -767,7 +770,10 @@ void process_request_queue(void)
770 start_check(request);
771 curl_multi_perform(curlm, &num_transfers);
772 } else if (pushing && request->state == NEED_PUSH) {
770 - start_mkcol(request);
773 + if (remote_dir_exists[request->sha1[0]])
774 + start_put(request);
775 + else
776 + start_mkcol(request);
777 curl_multi_perform(curlm, &num_transfers);
778 }
779 request = request->next;
@@ -1599,6 +1605,8 @@ int main(int argc, char **argv)
1605 break;
1606 }
1607
1608 + memset(remote_dir_exists, 0, 256);
1609 +
1610 curl_global_init(CURL_GLOBAL_ALL);
1611
1612 #ifdef USE_CURL_MULTI