提交 1462d1af 编写于 作者: T Tay Ray Chuan 提交者: Junio C Hamano

http-push: add trailing slash at arg-parse time, instead of later on

That way, we don't have to update repo->path and repo->path_len again
after adding the trailing slash.
Signed-off-by: NTay Ray Chuan <rctay89@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 dfc2dcd9
...@@ -1801,7 +1801,6 @@ int main(int argc, char **argv) ...@@ -1801,7 +1801,6 @@ int main(int argc, char **argv)
int new_refs; int new_refs;
struct ref *ref, *local_refs; struct ref *ref, *local_refs;
struct remote *remote; struct remote *remote;
char *rewritten_url = NULL;
git_extract_argv0_path(argv[0]); git_extract_argv0_path(argv[0]);
...@@ -1847,8 +1846,8 @@ int main(int argc, char **argv) ...@@ -1847,8 +1846,8 @@ int main(int argc, char **argv)
} }
if (!repo->url) { if (!repo->url) {
char *path = strstr(arg, "//"); char *path = strstr(arg, "//");
repo->url = arg; str_end_url_with_slash(arg, &repo->url);
repo->path_len = strlen(arg); repo->path_len = strlen(repo->url);
if (path) { if (path) {
repo->path = strchr(path+2, '/'); repo->path = strchr(path+2, '/');
if (repo->path) if (repo->path)
...@@ -1884,15 +1883,6 @@ int main(int argc, char **argv) ...@@ -1884,15 +1883,6 @@ int main(int argc, char **argv)
remote->url[remote->url_nr++] = repo->url; remote->url[remote->url_nr++] = repo->url;
http_init(remote); http_init(remote);
if (repo->url && repo->url[strlen(repo->url)-1] != '/') {
rewritten_url = xmalloc(strlen(repo->url)+2);
strcpy(rewritten_url, repo->url);
strcat(rewritten_url, "/");
repo->path = rewritten_url + (repo->path - repo->url);
repo->path_len++;
repo->url = rewritten_url;
}
#ifdef USE_CURL_MULTI #ifdef USE_CURL_MULTI
is_running_queue = 0; is_running_queue = 0;
#endif #endif
...@@ -2100,7 +2090,6 @@ int main(int argc, char **argv) ...@@ -2100,7 +2090,6 @@ int main(int argc, char **argv)
} }
cleanup: cleanup:
free(rewritten_url);
if (info_ref_lock) if (info_ref_lock)
unlock_remote(info_ref_lock); unlock_remote(info_ref_lock);
free(repo); free(repo);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册