Skip to content

Commit

Permalink
fetch: reject --no-ipv[46]
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gitster committed Jul 18, 2023
1 parent ae2c912 commit a2dad48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions parse-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions t/t5516-fetch-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
(
Expand Down

0 comments on commit a2dad48

Please sign in to comment.