connect: simplify SSH connection code path
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>
brian m. carlson committed
Apr 26, 2015 at 20:30 UTC
37ee646e72d7f39d61a538e21a4c2721e32cb444
1 file changed
+20
-20
connect.c
+20
-20
@@ -740,28 +740,28 @@ struct child_process *git_connect(int fd[2], const char *url,
740
free(hostandport);
741
free(path);
742
return NULL;
743
+ }
744
+
745
+ ssh = getenv("GIT_SSH_COMMAND");
746
+ if (ssh) {
747
+ conn->use_shell = 1;
748
+ putty = 0;
749
} else {
744
- ssh = getenv("GIT_SSH_COMMAND");
745
- if (ssh) {
746
- conn->use_shell = 1;
747
- putty = 0;
748
- } else {
749
- ssh = getenv("GIT_SSH");
750
- if (!ssh)
751
- ssh = "ssh";
752
- putty = !!strcasestr(ssh, "plink");
753
- }
754
-
755
- argv_array_push(&conn->args, ssh);
756
- if (putty && !strcasestr(ssh, "tortoiseplink"))
757
- argv_array_push(&conn->args, "-batch");
758
- if (port) {
759
- /* P is for PuTTY, p is for OpenSSH */
760
- argv_array_push(&conn->args, putty ? "-P" : "-p");
761
- argv_array_push(&conn->args, port);
762
- }
763
- argv_array_push(&conn->args, ssh_host);
750
+ ssh = getenv("GIT_SSH");
751
+ if (!ssh)
752
+ ssh = "ssh";
753
+ putty = !!strcasestr(ssh, "plink");
754
+ }
755
+
756
+ argv_array_push(&conn->args, ssh);
757
+ if (putty && !strcasestr(ssh, "tortoiseplink"))
758
+ argv_array_push(&conn->args, "-batch");
759
+ if (port) {
760
+ /* P is for PuTTY, p is for OpenSSH */
761
+ argv_array_push(&conn->args, putty ? "-P" : "-p");
762
+ argv_array_push(&conn->args, port);
763
}
764
+ argv_array_push(&conn->args, ssh_host);
765
} else {
766
/* remove repo-local variables from the environment */
767
conn->env = local_repo_env;