All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Hengeveld <nickh@reactrix.com>
To: git@vger.kernel.org
Subject: [PATCH] Make http-push smarter about creating remote dirs
Date: Mon, 7 Nov 2005 11:39:37 -0800	[thread overview]
Message-ID: <20051107193937.GA3788@reactrix.com> (raw)

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>


---

 http-push.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

applies-to: 27732582039ada9c7781ce5a1583ee682e0452c6
9904bed158b8c297bfba8a8cff87644619688b62
diff --git a/http-push.c b/http-push.c
index 96d2778..4d41b4f 100644
--- a/http-push.c
+++ b/http-push.c
@@ -56,6 +56,7 @@ static int active_requests = 0;
 static int data_received;
 static int pushing = 0;
 static int aborted = 0;
+static char remote_dir_exists[256];
 
 #ifdef USE_CURL_MULTI
 static int max_requests = -1;
@@ -669,6 +670,7 @@ static void finish_request(struct transf
 		if (request->http_code == 404) {
 			request->state = NEED_PUSH;
 		} else if (request->curl_result == CURLE_OK) {
+			remote_dir_exists[request->sha1[0]] = 1;
 			request->state = COMPLETE;
 		} else {
 			fprintf(stderr, "HEAD %s failed, aborting (%d/%ld)\n",
@@ -680,6 +682,7 @@ static void finish_request(struct transf
 	} else if (request->state == RUN_MKCOL) {
 		if (request->curl_result == CURLE_OK ||
 		    request->http_code == 405) {
+			remote_dir_exists[request->sha1[0]] = 1;
 			start_put(request);
 		} else {
 			fprintf(stderr, "MKCOL %s failed, aborting (%d/%ld)\n",
@@ -790,7 +793,10 @@ void process_request_queue(void)
 			start_check(request);
 			curl_multi_perform(curlm, &num_transfers);
 		} else if (pushing && request->state == NEED_PUSH) {
-			start_mkcol(request);
+			if (remote_dir_exists[request->sha1[0]])
+				start_put(request);
+			else
+				start_mkcol(request);
 			curl_multi_perform(curlm, &num_transfers);
 		}
 		request = request->next;
@@ -1622,6 +1628,8 @@ int main(int argc, char **argv)
 		break;
 	}
 
+	memset(remote_dir_exists, 0, 256);
+
 	curl_global_init(CURL_GLOBAL_ALL);
 
 #ifdef USE_CURL_MULTI
---
0.99.9.GIT

                 reply	other threads:[~2005-11-07 19:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051107193937.GA3788@reactrix.com \
    --to=nickh@reactrix.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.