summaryrefslogtreecommitdiff
path: root/http-fetch.c
diff options
context:
space:
mode:
authorTay Ray Chuan <rctay89@gmail.com>2010-11-25 16:21:10 +0800
committerJunio C Hamano <gitster@pobox.com>2010-11-26 14:50:46 -0800
commit6f5185bd2d87dff587e4900aa022f6f9bd088f20 (patch)
treebd1f8618a5383b039ab67de76f431e73ec0ae1a2 /http-fetch.c
parent1462d1af69247af5fa2b43f7b4fe61ec3c71b55a (diff)
downloadgit-6f5185bd2d87dff587e4900aa022f6f9bd088f20.tar.gz
http-fetch: rework url handling
Do away with a second url variable, rewritten_url, and make url non-const. This is safe because the functions called with url (ie. get_http_walker() and walker_fetch()) do not modify it (ie. marked with const char *). Also, replace code that adds a trailing slash with a call to str_end_url_with_slash(). Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-fetch.c')
-rw-r--r--http-fetch.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/http-fetch.c b/http-fetch.c
index 762c750d7a..923904f97f 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -14,8 +14,7 @@ int main(int argc, const char **argv)
int commits;
const char **write_ref = NULL;
char **commit_id;
- const char *url;
- char *rewritten_url = NULL;
+ char *url = NULL;
int arg = 1;
int rc = 0;
int get_tree = 0;
@@ -57,19 +56,14 @@ int main(int argc, const char **argv)
commit_id = (char **) &argv[arg++];
commits = 1;
}
- url = argv[arg];
+
+ if (argv[arg])
+ str_end_url_with_slash(argv[arg], &url);
prefix = setup_git_directory();
git_config(git_default_config, NULL);
- if (url && url[strlen(url)-1] != '/') {
- rewritten_url = xmalloc(strlen(url)+2);
- strcpy(rewritten_url, url);
- strcat(rewritten_url, "/");
- url = rewritten_url;
- }
-
http_init(NULL);
walker = get_http_walker(url);
walker->get_tree = get_tree;
@@ -93,7 +87,7 @@ int main(int argc, const char **argv)
walker_free(walker);
http_cleanup();
- free(rewritten_url);
+ free(url);
return rc;
}