git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] fetch: reject --no-ipv[46]
Date: Tue, 18 Jul 2023 14:45:59 -0700	[thread overview]
Message-ID: <xmqqedl4gag8.fsf@gitster.g> (raw)
In-Reply-To: <xmqqjzuwgaza.fsf@gitster.g> (Junio C. Hamano's message of "Tue, 18 Jul 2023 14:34:33 -0700")

Now we have introduced OPT_IPVERSION(), tweak its implementation so
that "git clone", "git fetch", and "git push" reject the negated
form of "Use only IP version N" options.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 parse-options.h       |  8 ++++----
 t/t5516-fetch-push.sh | 11 +++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git c/parse-options.h w/parse-options.h
index e35710733d..57a7fe9d91 100644
--- c/parse-options.h
+++ w/parse-options.h
@@ -582,9 +582,9 @@ int parse_opt_tracking_mode(const struct option *, const char *, int);
 #define OPT_AUTOSTASH(v) OPT_BOOL(0, "autostash", v, N_("automatically stash/stash pop before and after"))
 
 #define OPT_IPVERSION(v) \
-	OPT_SET_INT('4', "ipv4", (v), N_("use IPv4 addresses only"), \
-		TRANSPORT_FAMILY_IPV4), \
-	OPT_SET_INT('6', "ipv6", (v), N_("use IPv6 addresses only"), \
-		TRANSPORT_FAMILY_IPV6)
+	OPT_SET_INT_F('4', "ipv4", (v), N_("use IPv4 addresses only"), \
+		TRANSPORT_FAMILY_IPV4, PARSE_OPT_NONEG), \
+	OPT_SET_INT_F('6', "ipv6", (v), N_("use IPv6 addresses only"), \
+		TRANSPORT_FAMILY_IPV6, PARSE_OPT_NONEG)
 
 #endif
diff --git c/t/t5516-fetch-push.sh w/t/t5516-fetch-push.sh
index 19ebefa5ac..87163d7745 100755
--- c/t/t5516-fetch-push.sh
+++ w/t/t5516-fetch-push.sh
@@ -120,6 +120,17 @@ test_expect_success setup '
 
 '
 
+for cmd in push fetch
+do
+	for opt in ipv4 ipv6
+	do
+		test_expect_success "reject 'git $cmd --no-$opt'" '
+			test_must_fail git $cmd --no-$opt 2>err &&
+			grep "unknown option .no-$opt" err
+		'
+	done
+done
+
 test_expect_success 'fetch without wildcard' '
 	mk_empty testrepo &&
 	(


  reply	other threads:[~2023-07-18 21:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 21:34 [PATCH] parse-options: introduce OPT_IPVERSION() Junio C Hamano
2023-07-18 21:45 ` Junio C Hamano [this message]
2023-07-18 21:59   ` [PATCH] fetch: reject --no-ipv[46] Taylor Blau

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=xmqqedl4gag8.fsf@gitster.g \
    --to=gitster@pobox.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;
as well as URLs for NNTP newsgroup(s).