diff options
-rw-r--r-- | builtin-http-fetch.c | 10 | ||||
-rw-r--r-- | http-push.c | 11 |
2 files changed, 21 insertions, 0 deletions
diff --git a/builtin-http-fetch.c b/builtin-http-fetch.c index 4a50dbd95..7f450c61d 100644 --- a/builtin-http-fetch.c +++ b/builtin-http-fetch.c @@ -9,6 +9,7 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix) const char **write_ref = NULL; char **commit_id; const char *url; + char *rewritten_url = NULL; int arg = 1; int rc = 0; int get_tree = 0; @@ -51,6 +52,12 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix) commits = 1; } url = argv[arg]; + if (url && url[strlen(url)-1] != '/') { + rewritten_url = malloc(strlen(url)+2); + strcpy(rewritten_url, url); + strcat(rewritten_url, "/"); + url = rewritten_url; + } walker = get_http_walker(url); walker->get_tree = get_tree; @@ -73,5 +80,8 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix) walker_free(walker); + if (rewritten_url) + free(rewritten_url); + return rc; } diff --git a/http-push.c b/http-push.c index c221dce62..b2b410df9 100644 --- a/http-push.c +++ b/http-push.c @@ -2169,6 +2169,7 @@ int main(int argc, char **argv) int i; int new_refs; struct ref *ref; + char *rewritten_url = NULL; setup_git_directory(); @@ -2236,6 +2237,14 @@ int main(int argc, char **argv) no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:"); + if (remote->url && remote->url[strlen(remote->url)-1] != '/') { + rewritten_url = malloc(strlen(remote->url)+2); + strcpy(rewritten_url, remote->url); + strcat(rewritten_url, "/"); + remote->url = rewritten_url; + ++remote->path_len; + } + /* Verify DAV compliance/lock support */ if (!locking_available()) { rc = 1; @@ -2416,6 +2425,8 @@ int main(int argc, char **argv) } cleanup: + if (rewritten_url) + free(rewritten_url); if (info_ref_lock) unlock_remote(info_ref_lock); free(remote); |