Skip to content

Commit a2dad48

Browse files
committed
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 <[email protected]>
1 parent ae2c912 commit a2dad48

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

parse-options.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,9 @@ int parse_opt_tracking_mode(const struct option *, const char *, int);
582582
#define OPT_AUTOSTASH(v) OPT_BOOL(0, "autostash", v, N_("automatically stash/stash pop before and after"))
583583

584584
#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)
589589

590590
#endif

t/t5516-fetch-push.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ test_expect_success setup '
120120
121121
'
122122

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+
123134
test_expect_success 'fetch without wildcard' '
124135
mk_empty testrepo &&
125136
(

0 commit comments

Comments
 (0)