Skip to content

Commit

Permalink
connect: simplify SSH connection code path
Browse files Browse the repository at this point in the history
The code path used in git_connect pushed the majority of the SSH
connection code into an else block, even though the if block returns.
Simplify the code by eliminating the else block, as it is unneeded.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
brian m. carlson authored and Junio C Hamano committed Apr 28, 2015
1 parent 8c2ea51 commit 37ee646
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,28 +740,28 @@ struct child_process *git_connect(int fd[2], const char *url,
free(hostandport);
free(path);
return NULL;
}

ssh = getenv("GIT_SSH_COMMAND");
if (ssh) {
conn->use_shell = 1;
putty = 0;
} else {
ssh = getenv("GIT_SSH_COMMAND");
if (ssh) {
conn->use_shell = 1;
putty = 0;
} else {
ssh = getenv("GIT_SSH");
if (!ssh)
ssh = "ssh";
putty = !!strcasestr(ssh, "plink");
}

argv_array_push(&conn->args, ssh);
if (putty && !strcasestr(ssh, "tortoiseplink"))
argv_array_push(&conn->args, "-batch");
if (port) {
/* P is for PuTTY, p is for OpenSSH */
argv_array_push(&conn->args, putty ? "-P" : "-p");
argv_array_push(&conn->args, port);
}
argv_array_push(&conn->args, ssh_host);
ssh = getenv("GIT_SSH");
if (!ssh)
ssh = "ssh";
putty = !!strcasestr(ssh, "plink");
}

argv_array_push(&conn->args, ssh);
if (putty && !strcasestr(ssh, "tortoiseplink"))
argv_array_push(&conn->args, "-batch");
if (port) {
/* P is for PuTTY, p is for OpenSSH */
argv_array_push(&conn->args, putty ? "-P" : "-p");
argv_array_push(&conn->args, port);
}
argv_array_push(&conn->args, ssh_host);
} else {
/* remove repo-local variables from the environment */
conn->env = local_repo_env;
Expand Down

0 comments on commit 37ee646

Please sign in to comment.