commit 09838ffc9388f0cdbc316deb5eaae54ec4841207 from: Stefan Sperling date: Wed Mar 18 16:11:26 2020 UTC make got_fetch() expect URI information in parsed form commit - 82ebf666930f3ea5b44663d1fede65ed22282361 commit + 09838ffc9388f0cdbc316deb5eaae54ec4841207 blob - d5f868ebd9f8c1243aa2a30ef8688b5bc3b97826 blob + 2aa285a3281b14706191512d7f095677ed3fa2ef --- got/got.c +++ got/got.c @@ -971,7 +971,9 @@ done: static const struct got_error * cmd_clone(int argc, char *argv[]) { - char *uri, *branch_filter, *dirname; + const struct got_error *err = NULL; + const char *uri, *branch_filter, *dirname; + char *proto, *host, *port, *repo_name, *server_path; int ch; while ((ch = getopt(argc, argv, "b:")) != -1) { @@ -993,7 +995,21 @@ cmd_clone(int argc, char *argv[]) dirname = argv[1]; else usage_clone(); - return got_fetch(argv[0], branch_filter, dirname); + + err = got_fetch_parse_uri(&proto, &host, &port, &server_path, + &repo_name, argv[0]); + if (err) + goto done; + + err = got_fetch(proto, host, port, server_path, repo_name, + branch_filter, dirname); +done: + free(proto); + free(host); + free(port); + free(server_path); + free(repo_name); + return err; } static const struct got_error * blob - 33820f922ef8ee50b6236805c495361c960616a7 blob + 3af0abb9fe9bfa5b38d3eecfa6328ee6cbe3f661 --- include/got_fetch.h +++ include/got_fetch.h @@ -20,4 +20,6 @@ const struct got_error *got_fetch_parse_uri(char **, char **, char **, char **, char **, const char *); -const struct got_error* got_fetch(char *, char *, char *); +const struct got_error *got_fetch(const char *, const char *, + const char *, const char *, const char *, const char *, + const char *); blob - b4ee27f466629f5422a50913c157a5910cd95fd3 blob + ff271353f0679b85ebb06d45b1dbcbf0ef2500be --- lib/fetch.c +++ lib/fetch.c @@ -82,7 +82,8 @@ hassuffix(char *base, char *suf) } static const struct got_error * -dial_ssh(int *fetchfd, char *host, char *port, char *path, char *direction) +dial_ssh(int *fetchfd, const char *host, const char *port, const char *path, + const char *direction) { const struct got_error *error = NULL; int pid, pfd[2]; @@ -118,7 +119,8 @@ dial_ssh(int *fetchfd, char *host, char *port, char *p } static const struct got_error * -dial_git(int *fetchfd, char *host, char *port, char *path, char *direction) +dial_git(int *fetchfd, const char *host, const char *port, const char *path, + const char *direction) { const struct got_error *err = NULL; struct addrinfo hints, *servinfo, *p; @@ -277,9 +279,10 @@ done: } const struct got_error* -got_fetch(char *uri, char *branch_filter, char *destdir) +got_fetch(const char *proto, const char *host, const char *port, + const char *server_path, const char *repo_name, + const char *branch_filter, const char *destdir) { - char *proto, *host, *port, *repo_name, *server_path; int imsg_fetchfds[2], imsg_idxfds[2], fetchfd = -1; int packfd = -1, npackfd = -1, idxfd = -1, nidxfd = -1; int status, done = 0; @@ -298,10 +301,6 @@ got_fetch(char *uri, char *branch_filter, char *destdi TAILQ_INIT(&symrefs); fetchfd = -1; - err = got_fetch_parse_uri(&proto, &host, &port, &server_path, - &repo_name, uri); - if (err) - return err; if (destdir == NULL) { if (asprintf(&default_destdir, "%s.git", repo_name) == -1) return got_error_from_errno("asprintf");