fetch: reject --no-ipv[46]
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>
Junio C Hamano committed
Jul 18, 2023 at 14:45 UTC
a2dad4868bf0681f63fe10264c171b5a547324a5
2 files changed
+15
-4
parse-options.h
+4
-4
@@ -582,9 +582,9 @@ int parse_opt_tracking_mode(const struct option *, const char *, int);
582
#define OPT_AUTOSTASH(v) OPT_BOOL(0, "autostash", v, N_("automatically stash/stash pop before and after"))
583
584
#define OPT_IPVERSION(v) \
585
- OPT_SET_INT('4', "ipv4", (v), N_("use IPv4 addresses only"), \
586
- TRANSPORT_FAMILY_IPV4), \
587
- OPT_SET_INT('6', "ipv6", (v), N_("use IPv6 addresses only"), \
588
- TRANSPORT_FAMILY_IPV6)
585
+ OPT_SET_INT_F('4', "ipv4", (v), N_("use IPv4 addresses only"), \
586
+ TRANSPORT_FAMILY_IPV4, PARSE_OPT_NONEG), \
587
+ OPT_SET_INT_F('6', "ipv6", (v), N_("use IPv6 addresses only"), \
588
+ TRANSPORT_FAMILY_IPV6, PARSE_OPT_NONEG)
589
590
#endif
t/t5516-fetch-push.sh
+11
@@ -120,6 +120,17 @@ test_expect_success setup '
120
121
'
122
123
+for cmd in push fetch
124
+do
125
+ for opt in ipv4 ipv6
126
+ do
127
+ test_expect_success "reject 'git $cmd --no-$opt'" '
128
+ test_must_fail git $cmd --no-$opt 2>err &&
129
+ grep "unknown option .no-$opt" err
130
+ '
131
+ done
132
+done
133
+
134
test_expect_success 'fetch without wildcard' '
135
mk_empty testrepo &&
136
(