{"thread":{"id":"2353","subject":"[PATCH 2/4] Support remote references with slashes in their names","startedAt":"2005-11-04T22:22:25Z","lastAt":"2005-11-04T22:22:25Z","messageCount":1,"participants":["Nick Hengeveld"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"11160","messageId":"20051104222225.GE3001@reactrix.com","threadId":"2353","inReplyTo":null,"subject":"[PATCH 2/4] Support remote references with slashes in their names","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2005-11-04T22:22:25Z","receivedAt":"2005-11-04T22:22:25Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"Support remote references with slashes in their names\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n\n\n---\n\n http-push.c |   42 +++++++++++++++++++++++++++++++++++++++---\n 1 files changed, 39 insertions(+), 3 deletions(-)\n\napplies-to: 54e1d462248523bfac7d7c4b42e3b1ce1270fbd9\n33cd543dfe656dce9c5722e4fe6af22fa5a80e7e\ndiff --git a/http-push.c b/http-push.c\nindex 134d405..6a241aa 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1066,12 +1066,44 @@ char *lock_remote(char *file, int timeou\n \tstruct buffer out_buffer;\n \tchar *out_data;\n \tchar *url;\n+\tchar *ep;\n \tchar timeout_header[25];\n \tstruct curl_slist *dav_headers = NULL;\n \n \tif (lock_token != NULL)\n \t\tfree(lock_token);\n \n+\turl = xmalloc(strlen(remote->url) + strlen(file) + 1);\n+\tsprintf(url, \"%s%s\", remote->url, file);\n+\n+\t/* Make sure leading directories exist for the remote ref */\n+\tep = strchr(url + strlen(remote->url) + 11, '/');\n+\twhile (ep) {\n+\t\t*ep = 0;\n+\t\tslot = get_active_slot();\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n+\t\tif (start_active_slot(slot)) {\n+\t\t\trun_active_slot(slot);\n+\t\t\tif (slot->curl_result != CURLE_OK &&\n+\t\t\t    slot->http_code != 405) {\n+\t\t\t\tfprintf(stderr,\n+\t\t\t\t\t\"Unable to create branch path %s\\n\",\n+\t\t\t\t\turl);\n+\t\t\t\tfree(url);\n+\t\t\t\treturn NULL;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tfprintf(stderr, \"Unable to start request\\n\");\n+\t\t\tfree(url);\n+\t\t\treturn NULL;\n+\t\t}\n+\t\t*ep = '/';\n+\t\tep = strchr(ep + 1, '/');\n+\t}\n+\n \tout_buffer.size = strlen(LOCK_REQUEST) + strlen(git_default_email) - 2;\n \tout_data = xmalloc(out_buffer.size + 1);\n \tsnprintf(out_data, out_buffer.size + 1, LOCK_REQUEST, git_default_email);\n@@ -1079,8 +1111,6 @@ char *lock_remote(char *file, int timeou\n \tout_buffer.buffer = out_data;\n \n \tsprintf(timeout_header, \"Timeout: Second-%d\", timeout);\n-\turl = xmalloc(strlen(remote->url) + strlen(file) + 1);\n-\tsprintf(url, \"%s%s\", remote->url, file);\n \tdav_headers = curl_slist_append(dav_headers, timeout_header);\n \tdav_headers = curl_slist_append(dav_headers, \"Content-Type: text/xml\");\n \n@@ -1098,16 +1128,22 @@ char *lock_remote(char *file, int timeou\n \n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n-\t\tfree(out_data);\n \t\tif (slot->curl_result != CURLE_OK) {\n \t\t\tfprintf(stderr, \"Got HTTP error %ld\\n\", slot->http_code);\n+\t\t\tfree(url);\n+\t\t\tfree(out_data);\n \t\t\treturn NULL;\n \t\t}\n \t} else {\n+\t\tfree(url);\n \t\tfree(out_data);\n \t\tfprintf(stderr, \"Unable to start request\\n\");\n+\t\treturn NULL;\n \t}\n \n+\tfree(url);\n+\tfree(out_data);\n+\n \treturn strdup(lock_token);\n }\n \n---\n0.99.9.GIT\n"}]}