git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthias Aßhauer" <mha1993@live.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Raymond E. Pasco" <ray@ameretat.dev>,
	git@vger.kernel.org, Jonathan Nieder <jrnieder@gmail.com>,
	Stefan Beller <sbeller@google.com>
Subject: [PATCH] connect.c: clarify BUG() messages in push_ssh_options
Date: Sat, 25 Apr 2020 11:43:29 +0200	[thread overview]
Message-ID: <AM0PR04MB4771946E0134D9D875AB1A8AA5D10@AM0PR04MB4771.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <AM0PR04MB4771FB8BCD1EEB7E60EF54C7A5D00@AM0PR04MB4771.eurprd04.prod.outlook.com>

The current BUG() messages in push_ssh_options imply that calling push_ssh_options and passing VARIANT_AUTO is always a bug
and we should check for it once at the top of push_ssh_options instead of multiple times in various if statements. That is
not actually the case. When the caller passes CONNECT_IPV4, CONNECT_IPV6 or a custom port alongside VARIANT_AUTO we cannot
translate that to an option to the underlying SSH implementation without knowing the variant. As long as the caller does
not specify IPV4/IPV6 or a custom port, it is ok for the caller to leave the variant AUTO. Let's explicitly state that the
bug is in the combination of parameters.

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
---
  connect.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/connect.c b/connect.c
index 23013c6344..c15e60b13a 100644
--- a/connect.c
+++ b/connect.c
@@ -1118,7 +1118,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
  	if (flags & CONNECT_IPV4) {
  		switch (variant) {
  		case VARIANT_AUTO:
-			BUG("VARIANT_AUTO passed to push_ssh_options");
+			BUG("VARIANT_AUTO and CONNECT_IPV4 passed to push_ssh_options");
  		case VARIANT_SIMPLE:
  			die(_("ssh variant 'simple' does not support -4"));
  		case VARIANT_SSH:
@@ -1130,7 +1130,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
  	} else if (flags & CONNECT_IPV6) {
  		switch (variant) {
  		case VARIANT_AUTO:
-			BUG("VARIANT_AUTO passed to push_ssh_options");
+			BUG("VARIANT_AUTO and CONNECT_IPV6 passed to push_ssh_options");
  		case VARIANT_SIMPLE:
  			die(_("ssh variant 'simple' does not support -6"));
  		case VARIANT_SSH:
@@ -1147,7 +1147,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
  	if (port) {
  		switch (variant) {
  		case VARIANT_AUTO:
-			BUG("VARIANT_AUTO passed to push_ssh_options");
+			BUG("VARIANT_AUTO and a custom port passed to push_ssh_options");
  		case VARIANT_SIMPLE:
  			die(_("ssh variant 'simple' does not support setting port"));
  		case VARIANT_SSH:
-- 
2.17.1



      reply	other threads:[~2020-04-25  9:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  6:41 [PATCH] ssh: add 'ssh.keyfile' option Raymond E. Pasco
2020-04-23 11:21 ` [PATCH v2] " Raymond E. Pasco
2020-04-23 17:24   ` Johannes Sixt
2020-04-23 19:32     ` Junio C Hamano
2020-04-24  3:24     ` Raymond E. Pasco
2020-04-23 18:03   ` Matthias Aßhauer
2020-04-23 19:38     ` Junio C Hamano
2020-04-24  4:33       ` Matthias Aßhauer
2020-04-25  9:43         ` Matthias Aßhauer [this message]

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=AM0PR04MB4771946E0134D9D875AB1A8AA5D10@AM0PR04MB4771.eurprd04.prod.outlook.com \
    --to=mha1993@live.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=ray@ameretat.dev \
    --cc=sbeller@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).