summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1462d1a)
raw | patch | inline | side by side (parent: 1462d1a)
author | Tay Ray Chuan <rctay89@gmail.com> | |
Thu, 25 Nov 2010 08:21:10 +0000 (16:21 +0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 26 Nov 2010 22:50:46 +0000 (14:50 -0800) |
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>
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>
http-fetch.c | patch | blob | history |
diff --git a/http-fetch.c b/http-fetch.c
index 762c750d7af3651287c147034d3dead469453e7c..923904f97f9274d09a0a0b08543492f78a141f79 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
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;
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;
walker_free(walker);
http_cleanup();
- free(rewritten_url);
+ free(url);
return rc;
}