commit - 58e1925afe722162950dec4569724ce73de3a294
commit + 62a4c94cd911a5c1ff54c4787c05d0876d30f07b
blob - 30f18d73f2400e6ec8f308802a304bc81ae8ea20
blob + 9d94bcc7fe798d02d848eb8412826ad908be6367
--- got/got.c
+++ got/got.c
goto done;
if (verbosity >= 0)
- printf("Connected to %s:%s\n", host, port);
+ printf("Connected to %s%s%s\n", host,
+ port ? ":" : "", port ? port : "");
/* Create a config file git-fetch(1) can understand. */
gitconfig_path = got_repo_get_path_gitconfig(repo);
goto done;
if (verbosity >= 0)
- printf("Connected to \"%s\" %s:%s\n", remote->name, host, port);
+ printf("Connected to \"%s\" %s%s%s\n", remote->name, host,
+ port ? ":" : "", port ? port : "");
fpa.last_scaled_size[0] = '\0';
fpa.last_p_indexed = -1;
blob - 8edac2b231e81f398c49e2d59c055e3c84a443b1
blob + b5b03f3f8b3c2b8923bf764d7b8d82f18181c5eb
--- lib/fetch.c
+++ lib/fetch.c
const struct got_error *error = NULL;
int pid, pfd[2];
char cmd[64];
- char *argv[9];
+ char *argv[11];
int i = 0;
*fetchfd = -1;
+ if (port == NULL)
+ port = "22";
+
argv[0] = GOT_FETCH_PATH_SSH;
+ argv[1] = "-p";
+ argv[2] = (char *)port;
if (verbosity == -1) {
- argv[1 + i++] = "-q";
+ argv[3 + i++] = "-q";
} else {
/* ssh(1) allows up to 3 "-v" options. */
for (i = 0; i < MIN(3, verbosity); i++)
- argv[1 + i] = "-v";
+ argv[3 + i] = "-v";
}
- argv[1 + i] = "--";
- argv[2 + i] = (char *)host;
- argv[3 + i] = (char *)cmd;
- argv[4 + i] = (char *)path;
- argv[5 + i] = NULL;
+ argv[3 + i] = "--";
+ argv[4 + i] = (char *)host;
+ argv[5 + i] = (char *)cmd;
+ argv[6 + i] = (char *)path;
+ argv[7 + i] = NULL;
if (pipe(pfd) == -1)
return got_error_from_errno("pipe");
*fetchfd = -1;
+ if (port == NULL)
+ port = GOT_DEFAULT_GIT_PORT_STR;
+
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
/* Try parsing Git's "scp" style URL syntax. */
*proto = strdup("ssh");
if (proto == NULL) {
- err = got_error_from_errno("strdup");
- goto done;
- }
- *port = strdup("22");
- if (*port == NULL) {
err = got_error_from_errno("strdup");
goto done;
}
err = got_error_from_errno("strndup");
goto done;
}
- if (asprintf(port, "%u", GOT_DEFAULT_GIT_PORT) == -1) {
- err = got_error_from_errno("asprintf");
- goto done;
- }
}
}
blob - 31b97a896df4896b127a7424821636148ccc8a8a
blob + 1d4429c2303caf6a1a577319457466d945db73ed
--- regress/fetch/fetch_test.c
+++ regress/fetch/fetch_test.c
NULL, NULL, NULL, NULL, NULL, GOT_ERR_PARSE_URI },
{ "git://127.0.0.1/git/myrepo",
- "git", "127.0.0.1", GOT_DEFAULT_GIT_PORT_STR,
+ "git", "127.0.0.1", NULL,
"/git/myrepo", "myrepo", GOT_ERR_OK },
{ "http://127.0.0.1/git/myrepo",
- "http", "127.0.0.1", GOT_DEFAULT_GIT_PORT_STR,
+ "http", "127.0.0.1", NULL,
"/git/myrepo", "myrepo", GOT_ERR_OK },
{ "gopher://127.0.0.1/git/myrepo",
- "gopher", "127.0.0.1", GOT_DEFAULT_GIT_PORT_STR,
+ "gopher", "127.0.0.1", NULL,
"/git/myrepo", "myrepo", GOT_ERR_OK },
{ "git://127.0.0.1:22/git/myrepo",
"git", "127.0.0.1", "22", "/git/myrepo", "myrepo",
GOT_ERR_OK },
{ "git://127.0.0.1/git/repos/foo/bar/myrepo.git",
- "git", "127.0.0.1", GOT_DEFAULT_GIT_PORT_STR,
+ "git", "127.0.0.1", NULL,
"/git/repos/foo/bar/myrepo.git", "myrepo", GOT_ERR_OK },
{ "https://127.0.0.1/git/repos/foo/../bar/myrepo.git",
- "https", "127.0.0.1", GOT_DEFAULT_GIT_PORT_STR,
+ "https", "127.0.0.1", NULL,
"/git/repos/foo/../bar/myrepo.git", "myrepo",
GOT_ERR_OK },
GOT_ERR_OK },
{ "127.0.0.1:git/myrepo",
- "ssh", "127.0.0.1", "22", "git/myrepo", "myrepo",
+ "ssh", "127.0.0.1", NULL, "git/myrepo", "myrepo",
GOT_ERR_OK },
{ "127.0.0.1:/git/myrepo",
- "ssh", "127.0.0.1", "22", "/git/myrepo", "myrepo",
+ "ssh", "127.0.0.1", NULL, "/git/myrepo", "myrepo",
GOT_ERR_OK },
{ "127.0.0.1:22/git/myrepo",
- "ssh", "127.0.0.1", "22", "22/git/myrepo", "myrepo",
+ "ssh", "127.0.0.1", NULL, "22/git/myrepo", "myrepo",
GOT_ERR_OK },
};
int i;