aboutsummaryrefslogtreecommitdiff
path: root/builtin-http-fetch.c
diff options
context:
space:
mode:
authorGrégoire Barbier <gb@gbarbier.org>2008-01-19 16:22:50 +0100
committerJunio C Hamano <gitster@pobox.com>2008-01-20 15:18:34 -0800
commit3057ded057f17add305cd38fe0b73173e94c540e (patch)
tree2c8a5ec604c07cc23a60c1521ae5cbf83bcbb175 /builtin-http-fetch.c
parent325ce3959ccee623eb973136f41741ca4e0ca56e (diff)
downloadgit-3057ded057f17add305cd38fe0b73173e94c540e.tar.gz
git-3057ded057f17add305cd38fe0b73173e94c540e.tar.xz
http-push and http-fetch: handle URLs without trailing /
The URL to a repository http-push and http-fetch takes should have a trailing slash. Instead of failing the request, add it ourselves before attempting such a request. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-http-fetch.c')
-rw-r--r--builtin-http-fetch.c10
1 files changed, 10 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;
}