mirror of
https://github.com/git/git
synced 2024-10-01 06:05:20 +00:00
Merge branch 'rs/incompatible-options-messages' into maint-2.43
Clean-up code that handles combinations of incompatible options. * rs/incompatible-options-messages: worktree: simplify incompatibility message for --orphan and commit-ish worktree: standardize incompatibility messages clean: factorize incompatibility message revision, rev-parse: factorize incompatibility messages about - -exclude-hidden revision: use die_for_incompatible_opt3() for - -graph/--reverse/--walk-reflogs repack: use die_for_incompatible_opt3() for -A/-k/--cruft push: use die_for_incompatible_opt4() for - -delete/--tags/--all/--mirror
This commit is contained in:
commit
6479e121c2
|
@ -971,7 +971,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
|
|||
dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
|
||||
|
||||
if (ignored && ignored_only)
|
||||
die(_("-x and -X cannot be used together"));
|
||||
die(_("options '%s' and '%s' cannot be used together"), "-x", "-X");
|
||||
if (!ignored)
|
||||
setup_standard_excludes(&dir);
|
||||
if (ignored_only)
|
||||
|
|
|
@ -639,8 +639,10 @@ int cmd_push(int argc, const char **argv, const char *prefix)
|
|||
: &push_options_config);
|
||||
set_push_cert_flags(&flags, push_cert);
|
||||
|
||||
if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--delete", "--all/--branches/--mirror/--tags");
|
||||
die_for_incompatible_opt4(deleterefs, "--delete",
|
||||
tags, "--tags",
|
||||
flags & TRANSPORT_PUSH_ALL, "--all/--branches",
|
||||
flags & TRANSPORT_PUSH_MIRROR, "--mirror");
|
||||
if (deleterefs && argc < 2)
|
||||
die(_("--delete doesn't make sense without any refs"));
|
||||
|
||||
|
@ -677,19 +679,13 @@ int cmd_push(int argc, const char **argv, const char *prefix)
|
|||
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
|
||||
|
||||
if (flags & TRANSPORT_PUSH_ALL) {
|
||||
if (tags)
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--all", "--tags");
|
||||
if (argc >= 2)
|
||||
die(_("--all can't be combined with refspecs"));
|
||||
}
|
||||
if (flags & TRANSPORT_PUSH_MIRROR) {
|
||||
if (tags)
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--mirror", "--tags");
|
||||
if (argc >= 2)
|
||||
die(_("--mirror can't be combined with refspecs"));
|
||||
}
|
||||
if ((flags & TRANSPORT_PUSH_ALL) && (flags & TRANSPORT_PUSH_MIRROR))
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--all", "--mirror");
|
||||
|
||||
if (!is_empty_cas(&cas) && (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES))
|
||||
cas.use_force_if_includes = 1;
|
||||
|
|
|
@ -1203,19 +1203,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
|||
if (delete_redundant && repository_format_precious_objects)
|
||||
die(_("cannot delete packs in a precious-objects repo"));
|
||||
|
||||
if (keep_unreachable &&
|
||||
(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE)))
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--keep-unreachable", "-A");
|
||||
die_for_incompatible_opt3(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE), "-A",
|
||||
keep_unreachable, "-k/--keep-unreachable",
|
||||
pack_everything & PACK_CRUFT, "--cruft");
|
||||
|
||||
if (pack_everything & PACK_CRUFT) {
|
||||
if (pack_everything & PACK_CRUFT)
|
||||
pack_everything |= ALL_INTO_ONE;
|
||||
|
||||
if (unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE))
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--cruft", "-A");
|
||||
if (keep_unreachable)
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--cruft", "-k");
|
||||
}
|
||||
|
||||
if (write_bitmaps < 0) {
|
||||
if (!write_midx &&
|
||||
(!(pack_everything & ALL_INTO_ONE) || !is_bare_repository()))
|
||||
|
|
|
@ -893,13 +893,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||
}
|
||||
if (opt_with_value(arg, "--branches", &arg)) {
|
||||
if (ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --branches"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--branches");
|
||||
handle_ref_opt(arg, "refs/heads/");
|
||||
continue;
|
||||
}
|
||||
if (opt_with_value(arg, "--tags", &arg)) {
|
||||
if (ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --tags"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--tags");
|
||||
handle_ref_opt(arg, "refs/tags/");
|
||||
continue;
|
||||
}
|
||||
|
@ -909,7 +911,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||
}
|
||||
if (opt_with_value(arg, "--remotes", &arg)) {
|
||||
if (ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --remotes"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--remotes");
|
||||
handle_ref_opt(arg, "refs/remotes/");
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -730,11 +730,11 @@ static int dwim_orphan(const struct add_opts *opts, int opt_track, int remote)
|
|||
}
|
||||
|
||||
if (opt_track) {
|
||||
die(_("'%s' and '%s' cannot be used together"), "--orphan",
|
||||
"--track");
|
||||
die(_("options '%s' and '%s' cannot be used together"),
|
||||
"--orphan", "--track");
|
||||
} else if (!opts->checkout) {
|
||||
die(_("'%s' and '%s' cannot be used together"), "--orphan",
|
||||
"--no-checkout");
|
||||
die(_("options '%s' and '%s' cannot be used together"),
|
||||
"--orphan", "--no-checkout");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -806,16 +806,17 @@ static int add(int ac, const char **av, const char *prefix)
|
|||
if (!!opts.detach + !!new_branch + !!new_branch_force > 1)
|
||||
die(_("options '%s', '%s', and '%s' cannot be used together"), "-b", "-B", "--detach");
|
||||
if (opts.detach && opts.orphan)
|
||||
die(_("options '%s', and '%s' cannot be used together"),
|
||||
die(_("options '%s' and '%s' cannot be used together"),
|
||||
"--orphan", "--detach");
|
||||
if (opts.orphan && opt_track)
|
||||
die(_("'%s' and '%s' cannot be used together"), "--orphan", "--track");
|
||||
die(_("options '%s' and '%s' cannot be used together"),
|
||||
"--orphan", "--track");
|
||||
if (opts.orphan && !opts.checkout)
|
||||
die(_("'%s' and '%s' cannot be used together"), "--orphan",
|
||||
"--no-checkout");
|
||||
die(_("options '%s' and '%s' cannot be used together"),
|
||||
"--orphan", "--no-checkout");
|
||||
if (opts.orphan && ac == 2)
|
||||
die(_("'%s' and '%s' cannot be used together"), "--orphan",
|
||||
_("<commit-ish>"));
|
||||
die(_("option '%s' and commit-ish cannot be used together"),
|
||||
"--orphan");
|
||||
if (lock_reason && !keep_locked)
|
||||
die(_("the option '%s' requires '%s'"), "--reason", "--lock");
|
||||
if (lock_reason)
|
||||
|
|
27
revision.c
27
revision.c
|
@ -2728,7 +2728,8 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
|
|||
clear_ref_exclusions(&revs->ref_excludes);
|
||||
} else if (!strcmp(arg, "--branches")) {
|
||||
if (revs->ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --branches"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--branches");
|
||||
handle_refs(refs, revs, *flags, refs_for_each_branch_ref);
|
||||
clear_ref_exclusions(&revs->ref_excludes);
|
||||
} else if (!strcmp(arg, "--bisect")) {
|
||||
|
@ -2739,12 +2740,14 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
|
|||
revs->bisect = 1;
|
||||
} else if (!strcmp(arg, "--tags")) {
|
||||
if (revs->ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --tags"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--tags");
|
||||
handle_refs(refs, revs, *flags, refs_for_each_tag_ref);
|
||||
clear_ref_exclusions(&revs->ref_excludes);
|
||||
} else if (!strcmp(arg, "--remotes")) {
|
||||
if (revs->ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --remotes"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--remotes");
|
||||
handle_refs(refs, revs, *flags, refs_for_each_remote_ref);
|
||||
clear_ref_exclusions(&revs->ref_excludes);
|
||||
} else if ((argcount = parse_long_opt("glob", argv, &optarg))) {
|
||||
|
@ -2762,21 +2765,24 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
|
|||
} else if (skip_prefix(arg, "--branches=", &optarg)) {
|
||||
struct all_refs_cb cb;
|
||||
if (revs->ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --branches"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--branches");
|
||||
init_all_refs_cb(&cb, revs, *flags);
|
||||
for_each_glob_ref_in(handle_one_ref, optarg, "refs/heads/", &cb);
|
||||
clear_ref_exclusions(&revs->ref_excludes);
|
||||
} else if (skip_prefix(arg, "--tags=", &optarg)) {
|
||||
struct all_refs_cb cb;
|
||||
if (revs->ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --tags"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--tags");
|
||||
init_all_refs_cb(&cb, revs, *flags);
|
||||
for_each_glob_ref_in(handle_one_ref, optarg, "refs/tags/", &cb);
|
||||
clear_ref_exclusions(&revs->ref_excludes);
|
||||
} else if (skip_prefix(arg, "--remotes=", &optarg)) {
|
||||
struct all_refs_cb cb;
|
||||
if (revs->ref_excludes.hidden_refs_configured)
|
||||
return error(_("--exclude-hidden cannot be used together with --remotes"));
|
||||
return error(_("options '%s' and '%s' cannot be used together"),
|
||||
"--exclude-hidden", "--remotes");
|
||||
init_all_refs_cb(&cb, revs, *flags);
|
||||
for_each_glob_ref_in(handle_one_ref, optarg, "refs/remotes/", &cb);
|
||||
clear_ref_exclusions(&revs->ref_excludes);
|
||||
|
@ -3055,8 +3061,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
|||
revs->grep_filter.ignore_locale = 1;
|
||||
compile_grep_patterns(&revs->grep_filter);
|
||||
|
||||
if (revs->reverse && revs->reflog_info)
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--reverse", "--walk-reflogs");
|
||||
if (revs->reflog_info && revs->limited)
|
||||
die("cannot combine --walk-reflogs with history-limiting options");
|
||||
if (revs->rewrite_parents && revs->children.name)
|
||||
|
@ -3067,11 +3071,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
|||
/*
|
||||
* Limitations on the graph functionality
|
||||
*/
|
||||
if (revs->reverse && revs->graph)
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--reverse", "--graph");
|
||||
die_for_incompatible_opt3(!!revs->graph, "--graph",
|
||||
!!revs->reverse, "--reverse",
|
||||
!!revs->reflog_info, "--walk-reflogs");
|
||||
|
||||
if (revs->reflog_info && revs->graph)
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--walk-reflogs", "--graph");
|
||||
if (revs->no_walk && revs->graph)
|
||||
die(_("options '%s' and '%s' cannot be used together"), "--no-walk", "--graph");
|
||||
if (!revs->reflog_info && revs->grep_filter.use_reflog_filter)
|
||||
|
|
|
@ -711,7 +711,7 @@ test_dwim_orphan () {
|
|||
local fetch_error_text="fatal: No local or remote refs exist despite at least one remote" &&
|
||||
local orphan_hint="hint: If you meant to create a worktree containing a new orphan branch" &&
|
||||
local invalid_ref_regex="^fatal: invalid reference: " &&
|
||||
local bad_combo_regex="^fatal: '[-a-z]*' and '[-a-z]*' cannot be used together" &&
|
||||
local bad_combo_regex="^fatal: options '[-a-z]*' and '[-a-z]*' cannot be used together" &&
|
||||
|
||||
local git_ns="repo" &&
|
||||
local dashc_args="-C $git_ns" &&
|
||||
|
|
|
@ -214,15 +214,13 @@ do
|
|||
for pseudoopt in branches tags remotes
|
||||
do
|
||||
test_expect_success "rev-parse --exclude-hidden=$section fails with --$pseudoopt" '
|
||||
echo "error: --exclude-hidden cannot be used together with --$pseudoopt" >expected &&
|
||||
test_must_fail git rev-parse --exclude-hidden=$section --$pseudoopt 2>err &&
|
||||
test_cmp expected err
|
||||
test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
|
||||
'
|
||||
|
||||
test_expect_success "rev-parse --exclude-hidden=$section fails with --$pseudoopt=pattern" '
|
||||
echo "error: --exclude-hidden cannot be used together with --$pseudoopt" >expected &&
|
||||
test_must_fail git rev-parse --exclude-hidden=$section --$pseudoopt=pattern 2>err &&
|
||||
test_cmp expected err
|
||||
test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
|
||||
'
|
||||
done
|
||||
done
|
||||
|
|
|
@ -151,12 +151,12 @@ do
|
|||
do
|
||||
test_expect_success "$section: fails with --$pseudoopt" '
|
||||
test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt 2>err &&
|
||||
test_grep "error: --exclude-hidden cannot be used together with --$pseudoopt" err
|
||||
test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
|
||||
'
|
||||
|
||||
test_expect_success "$section: fails with --$pseudoopt=pattern" '
|
||||
test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt=pattern 2>err &&
|
||||
test_grep "error: --exclude-hidden cannot be used together with --$pseudoopt" err
|
||||
test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
|
||||
'
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue