@matheusbsbs / matheus-bagliano / commits / 1462d1af69
Fork 0

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: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tay Ray Chuan committed Nov 25, 2010 at 16:21 UTC 1462d1af69247af5fa2b43f7b4fe61ec3c71b55a
1 file changed +2 -13
http-push.c
+2 -13
@@ -1801,7 +1801,6 @@ int main(int argc, char **argv)
1801 int new_refs;
1802 struct ref *ref, *local_refs;
1803 struct remote *remote;
1804 - char *rewritten_url = NULL;
1804
1805 git_extract_argv0_path(argv[0]);
1806
@@ -1847,8 +1846,8 @@ int main(int argc, char **argv)
1846 }
1847 if (!repo->url) {
1848 char *path = strstr(arg, "//");
1850 - repo->url = arg;
1851 - repo->path_len = strlen(arg);
1849 + str_end_url_with_slash(arg, &repo->url);
1850 + repo->path_len = strlen(repo->url);
1851 if (path) {
1852 repo->path = strchr(path+2, '/');
1853 if (repo->path)
@@ -1884,15 +1883,6 @@ int main(int argc, char **argv)
1883 remote->url[remote->url_nr++] = repo->url;
1884 http_init(remote);
1885
1887 - if (repo->url && repo->url[strlen(repo->url)-1] != '/') {
1888 - rewritten_url = xmalloc(strlen(repo->url)+2);
1889 - strcpy(rewritten_url, repo->url);
1890 - strcat(rewritten_url, "/");
1891 - repo->path = rewritten_url + (repo->path - repo->url);
1892 - repo->path_len++;
1893 - repo->url = rewritten_url;
1894 - }
1895 -
1886 #ifdef USE_CURL_MULTI
1887 is_running_queue = 0;
1888 #endif
@@ -2100,7 +2090,6 @@ int main(int argc, char **argv)
2090 }
2091
2092 cleanup:
2103 - free(rewritten_url);
2093 if (info_ref_lock)
2094 unlock_remote(info_ref_lock);
2095 free(repo);