Thread (3 messages) flat view 3 messages, 3 authors, 2017-01-26

Re: [PATCH] connect: handle putty/plink also in GIT_SSH_COMMAND

From: Jeff King <hidden>
Date: 2017-01-25 22:41:03

Possibly related (same subject, not in this thread)

On Wed, Jan 25, 2017 at 02:35:36PM -0800, Junio C Hamano wrote:
-- >8 --
Subject: [PATCH] connect: core.sshvariant to correct misidentification
I have been watching this discussion from the sidelines, and I agree
that this direction is a big improvement.
+static void override_ssh_variant(int *port_option, int *needs_batch)
+{
+	const char *variant;
+
+	if (git_config_get_string_const("core.sshvariant", &variant))
+		return;
+	if (!strcmp(variant, "tortoiseplink")) {
+		*port_option = 'P';
+		*needs_batch = 1;
+	} else if (!strcmp(variant, "putty")) {
+		*port_option = 'P';
+		*needs_batch = 0;
+	} else {
+		/* default */
+		if (strcmp(variant, "ssh")) {
+			warning(_("core.sshvariant: unknown value '%s'"), variant);
+			warning(_("using OpenSSH compatible behaviour"));
+		}
+		*port_option = 'p';
+		*needs_batch = 0;
+	}
+}
IIRC, the "const" in git_config_get_string_const is only about avoiding
an annoying cast. The result is still allocated and needs freed. Since
you are not keeping the value after the function returns, I think you
could just use git_config_get_value().

(Grepping around, I see a few other places that seem to make the same
mistake. I think this is a confusing interface that should probably be
fixed).

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help