{"thread":{"id":"2389","subject":"[PATCH] Make http-push smarter about creating remote dirs","startedAt":"2005-11-07T19:39:37Z","lastAt":"2005-11-07T19:39:37Z","messageCount":1,"participants":["Nick Hengeveld"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"11269","messageId":"20051107193937.GA3788@reactrix.com","threadId":"2389","inReplyTo":null,"subject":"[PATCH] Make http-push smarter about creating remote dirs","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2005-11-07T19:39:37Z","receivedAt":"2005-11-07T19:39:37Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"Remember object directories known to exist in the remote repo and don't\nbother trying to create them.\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n\n\n---\n\n http-push.c |   10 +++++++++-\n 1 files changed, 9 insertions(+), 1 deletions(-)\n\napplies-to: 27732582039ada9c7781ce5a1583ee682e0452c6\n9904bed158b8c297bfba8a8cff87644619688b62\ndiff --git a/http-push.c b/http-push.c\nindex 96d2778..4d41b4f 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -56,6 +56,7 @@ static int active_requests = 0;\n static int data_received;\n static int pushing = 0;\n static int aborted = 0;\n+static char remote_dir_exists[256];\n \n #ifdef USE_CURL_MULTI\n static int max_requests = -1;\n@@ -669,6 +670,7 @@ static void finish_request(struct transf\n \t\tif (request->http_code == 404) {\n \t\t\trequest->state = NEED_PUSH;\n \t\t} else if (request->curl_result == CURLE_OK) {\n+\t\t\tremote_dir_exists[request->sha1[0]] = 1;\n \t\t\trequest->state = COMPLETE;\n \t\t} else {\n \t\t\tfprintf(stderr, \"HEAD %s failed, aborting (%d/%ld)\\n\",\n@@ -680,6 +682,7 @@ static void finish_request(struct transf\n \t} else if (request->state == RUN_MKCOL) {\n \t\tif (request->curl_result == CURLE_OK ||\n \t\t    request->http_code == 405) {\n+\t\t\tremote_dir_exists[request->sha1[0]] = 1;\n \t\t\tstart_put(request);\n \t\t} else {\n \t\t\tfprintf(stderr, \"MKCOL %s failed, aborting (%d/%ld)\\n\",\n@@ -790,7 +793,10 @@ void process_request_queue(void)\n \t\t\tstart_check(request);\n \t\t\tcurl_multi_perform(curlm, &num_transfers);\n \t\t} else if (pushing && request->state == NEED_PUSH) {\n-\t\t\tstart_mkcol(request);\n+\t\t\tif (remote_dir_exists[request->sha1[0]])\n+\t\t\t\tstart_put(request);\n+\t\t\telse\n+\t\t\t\tstart_mkcol(request);\n \t\t\tcurl_multi_perform(curlm, &num_transfers);\n \t\t}\n \t\trequest = request->next;\n@@ -1622,6 +1628,8 @@ int main(int argc, char **argv)\n \t\tbreak;\n \t}\n \n+\tmemset(remote_dir_exists, 0, 256);\n+\n \tcurl_global_init(CURL_GLOBAL_ALL);\n \n #ifdef USE_CURL_MULTI\n---\n0.99.9.GIT\n"}]}