[PATCH v4 09/11] connect: use "-l user" instead of "user@" on ssh command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While it is not strictly necessary, it makes the connect code simpler
when there is user.

Signed-off-by: Mike Hommey <mh@xxxxxxxxxxxx>
---
 connect.c        | 12 ++++--------
 t/t5601-clone.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 48 insertions(+), 16 deletions(-)

This is entirely optional.

diff --git a/connect.c b/connect.c
index 2c5b722..0cec822 100644
--- a/connect.c
+++ b/connect.c
@@ -812,14 +812,10 @@ struct child_process *git_connect(int fd[2], const char *url,
 				argv_array_push(&conn->args, port);
 			}
 			if (user) {
-				struct strbuf userandhost = STRBUF_INIT;
-				strbuf_addstr(&userandhost, user);
-				strbuf_addch(&userandhost, '@');
-				strbuf_addstr(&userandhost, host);
-				argv_array_push(&conn->args, userandhost.buf);
-				strbuf_release(&userandhost);
-			} else
-				argv_array_push(&conn->args, host);
+				argv_array_push(&conn->args, "-l");
+				argv_array_push(&conn->args, user);
+			}
+			argv_array_push(&conn->args, host);
 		} else {
 			transport_check_allowed("file");
 		}
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index c1efb8e..98fe861 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -464,38 +464,74 @@ test_expect_success 'clone ssh://host.xz:22/~repo' '
 '
 
 #IPv6
-for tuah in ::1 [::1] [::1]: user@::1 user@[::1] user@[::1]: [user@::1] [user@::1]:
+for tah in ::1 [::1] [::1]:
+do
+	ehost=$(echo $tah | sed -e "s/1]:/1]/ "| tr -d "[]")
+	test_expect_success "clone ssh://$tah/home/user/repo" "
+	  test_clone_url ssh://$tah/home/user/repo $ehost /home/user/repo
+	"
+done
+
+for tuah in user@::1 user@[::1] user@[::1]: [user@::1] [user@::1]:
 do
 	ehost=$(echo $tuah | sed -e "s/1]:/1]/ "| tr -d "[]")
+	ehost=${ehost#user@}
 	test_expect_success "clone ssh://$tuah/home/user/repo" "
-	  test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
+	  test_clone_url ssh://$tuah/home/user/repo '-l user $ehost' /home/user/repo
 	"
 done
 
 #IPv6 from home directory
-for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
+for tah in ::1 [::1]
+do
+	eah=$(echo $tah | tr -d "[]")
+	test_expect_success "clone ssh://$tah/~repo" "
+	  test_clone_url ssh://$tah/~repo $eah '~repo'
+	"
+done
+
+for tuah in user@::1 user@[::1] [user@::1]
 do
 	euah=$(echo $tuah | tr -d "[]")
+	eah=${euah#user@}
 	test_expect_success "clone ssh://$tuah/~repo" "
-	  test_clone_url ssh://$tuah/~repo $euah '~repo'
+	  test_clone_url ssh://$tuah/~repo '-l user' $eah '~repo'
 	"
 done
 
 #IPv6 with port number
-for tuah in [::1] user@[::1] [user@::1]
+for tah in [::1]
+do
+	eah=$(echo $tah | tr -d "[]")
+	test_expect_success "clone ssh://$tah:22/home/user/repo" "
+	  test_clone_url ssh://$tah:22/home/user/repo '-p 22' $eah /home/user/repo
+	"
+done
+
+for tuah in user@[::1] [user@::1]
 do
 	euah=$(echo $tuah | tr -d "[]")
+	eah=${euah#user@}
 	test_expect_success "clone ssh://$tuah:22/home/user/repo" "
-	  test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo
+	  test_clone_url ssh://$tuah:22/home/user/repo '-p 22 -l user' $eah /home/user/repo
 	"
 done
 
 #IPv6 from home directory with port number
-for tuah in [::1] user@[::1] [user@::1]
+for tah in [::1]
+do
+	eah=$(echo $tah | tr -d "[]")
+	test_expect_success "clone ssh://$tah:22/~repo" "
+	  test_clone_url ssh://$tah:22/~repo '-p 22' $eah '~repo'
+	"
+done
+
+for tuah in user@[::1] [user@::1]
 do
 	euah=$(echo $tuah | tr -d "[]")
+	eah=${euah#user@}
 	test_expect_success "clone ssh://$tuah:22/~repo" "
-	  test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
+	  test_clone_url ssh://$tuah:22/~repo '-p 22 -l user' $eah '~repo'
 	"
 done
 
-- 
2.8.1.16.gaa70619.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]