Git development
 help / color / mirror / Atom feed
From: "Maciej Małecki" <me@mmalecki.com>
To: git@vger.kernel.org
Cc: "Maciej Małecki" <me@mmalecki.com>
Subject: [PATCH] Use SSH key from `GIT_SSH_KEY` variable if supplied
Date: Tue, 20 Mar 2012 02:39:17 +0100	[thread overview]
Message-ID: <1332207557-10965-1-git-send-email-me@mmalecki.com> (raw)

Using a different SSH key for various SSH commands seems to be a
recurring theme. Allow user to supply path to the SSH key he wants to
use for operations that require it without need to use `GIT_SSH`
variable and a wrapper script.

Signed-off-by: Maciej Małecki <me@mmalecki.com>
---
 connect.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/connect.c b/connect.c
index 912cdde..dd3489d 100644
--- a/connect.c
+++ b/connect.c
@@ -575,8 +575,9 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 		die("command line too long");
 
 	conn->in = conn->out = -1;
-	conn->argv = arg = xcalloc(7, sizeof(*arg));
+	conn->argv = arg = xcalloc(9, sizeof(*arg));
 	if (protocol == PROTO_SSH) {
+		const char *key;
 		const char *ssh = getenv("GIT_SSH");
 		int putty = ssh && strcasestr(ssh, "plink");
 		if (!ssh) ssh = "ssh";
@@ -589,6 +590,13 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 			*arg++ = putty ? "-P" : "-p";
 			*arg++ = port;
 		}
+
+		key = getenv("GIT_SSH_KEY");
+		if (key) {
+			*arg++ = "-i";
+			*arg++ = key;
+		}
+
 		*arg++ = host;
 	}
 	else {
-- 
1.7.7.4

             reply	other threads:[~2012-03-20  1:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-20  1:39 Maciej Małecki [this message]
2012-03-20  1:55 ` [PATCH] Use SSH key from `GIT_SSH_KEY` variable if supplied Junio C Hamano
2012-03-20  2:07   ` Robin H. Johnson
2012-03-20  8:07     ` Maciej Małecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332207557-10965-1-git-send-email-me@mmalecki.com \
    --to=me@mmalecki.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox