Re: [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]

 



On Tue, May 3, 2016 at 4:50 AM, Mike Hommey <mh@xxxxxxxxxxxx> wrote:
> While it is not strictly necessary, it makes the connect code simpler
> when there is user.
>
> Signed-off-by: Mike Hommey <mh@xxxxxxxxxxxx>
> ---
> diff --git a/connect.c b/connect.c
> @@ -812,14 +812,10 @@ struct child_process *git_connect(int fd[2], const char *url,
>                         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);

Even simpler would be a one-liner for the user case:

    if (user)
        argv_array_pushf(&conn->args, "%s@%s"", user, host);
    else
        argv_array_push(&conn->args, host);

>                 } else {
>                         transport_check_allowed("file");
>                 }
--
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]