commit 09f630849f5a9cc540b1289cdd7a034b171fa7d4 from: Stefan Sperling date: Fri Mar 20 15:33:01 2020 UTC use one consistent way to compute the Git URL to write to the config file commit - 62a4c94cd911a5c1ff54c4787c05d0876d30f07b commit + 09f630849f5a9cc540b1289cdd7a034b171fa7d4 blob - 9d94bcc7fe798d02d848eb8412826ad908be6367 blob + 74366142a8b460dd0ad22df86bdd774bea7281a0 --- got/got.c +++ got/got.c @@ -942,7 +942,14 @@ cmd_clone(int argc, char *argv[]) error = got_fetch_parse_uri(&proto, &host, &port, &server_path, &repo_name, argv[0]); if (error) + goto done; + + if (asprintf(&git_url, "%s://%s%s%s%s%s", proto, + host, port ? ":" : "", port ? port : "", + server_path[0] != '/' ? "/" : "", server_path) == -1) { + error = got_error_from_errno("asprintf"); goto done; + } if (strcmp(proto, "git") == 0) { #ifndef PROFILE @@ -950,11 +957,6 @@ cmd_clone(int argc, char *argv[]) "sendfd dns inet unveil", NULL) == -1) err(1, "pledge"); #endif - git_url = strdup(argv[0]); - if (git_url == NULL) { - error = got_error_from_errno("strdup"); - goto done; - } } else if (strcmp(proto, "git+ssh") == 0 || strcmp(proto, "ssh") == 0) { #ifndef PROFILE @@ -962,11 +964,6 @@ cmd_clone(int argc, char *argv[]) "sendfd unveil", NULL) == -1) err(1, "pledge"); #endif - if (asprintf(&git_url, "ssh://%s:%s/%s", host, port, - server_path) == -1) { - error = got_error_from_errno("asprintf"); - goto done; - } } else if (strcmp(proto, "http") == 0 || strcmp(proto, "git+http") == 0) { error = got_error_path(proto, GOT_ERR_NOT_IMPL);