summaryrefslogtreecommitdiff
path: root/http-push.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2009-01-17 16:11:51 +0100
committerJunio C Hamano <gitster@pobox.com>2009-01-17 18:19:46 -0800
commit466ddf90c2f270b973d141f20e912f743743331c (patch)
tree0a238a1c9d8c2597874dd6b8ecfb243b5812f851 /http-push.c
parent20642801e44a03362d1809644bf4da6473636529 (diff)
downloadgit-466ddf90c2f270b973d141f20e912f743743331c.tar.gz
http-push: when making directories, have a trailing slash in the path name
The function lock_remote() sends MKCOL requests to make leading directories; However, if it does not put a forward slash '/' at the end of the path, the server sends a 301 redirect. By leaving the '/' in place, we can avoid this additional step. Incidentally, at least one version of Curl (7.16.3) does not resend credentials when it follows a 301 redirect, so this commit also fixes a bug. Original patch by Tay Ray Chuan <rctay89@gmail.com>. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-push.c')
-rw-r--r--http-push.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/http-push.c b/http-push.c
index 2f20995700..6ad853e2d0 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1201,7 +1201,8 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
/* Make sure leading directories exist for the remote ref */
ep = strchr(url + strlen(remote->url) + 1, '/');
while (ep) {
- *ep = 0;
+ char saved_character = ep[1];
+ ep[1] = '\0';
slot = get_active_slot();
slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
@@ -1223,7 +1224,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
free(url);
return NULL;
}
- *ep = '/';
+ ep[1] = saved_character;
ep = strchr(ep + 1, '/');
}