push: use die_for_incompatible_opt4() for - -delete/--tags/--all/--mirror
The push option --delete is incompatible with --all, --mirror, and --tags; --tags is incompatible with --all and --mirror; --all is incompatible with --mirror. This means they are all incompatible with each other. And --branches is an alias for --all. Use the function for checking four mutually incompatible options, die_for_incompatible_opt4(), to perform this check in one place and without repetition. This is shorter and clearer. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Dec 6, 2023 at 12:51 UTC
b3bf4701cf617e5dc76e27f318913c2c76c35334
1 file changed
+4
-8
builtin/push.c
+4
-8
@@ -639,8 +639,10 @@ int cmd_push(int argc, const char **argv, const char *prefix)
639
: &push_options_config);
640
set_push_cert_flags(&flags, push_cert);
641
642
- if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
643
- die(_("options '%s' and '%s' cannot be used together"), "--delete", "--all/--branches/--mirror/--tags");
642
+ die_for_incompatible_opt4(deleterefs, "--delete",
643
+ tags, "--tags",
644
+ flags & TRANSPORT_PUSH_ALL, "--all/--branches",
645
+ flags & TRANSPORT_PUSH_MIRROR, "--mirror");
646
if (deleterefs && argc < 2)
647
die(_("--delete doesn't make sense without any refs"));
648
@@ -677,19 +679,13 @@ int cmd_push(int argc, const char **argv, const char *prefix)
679
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
680
681
if (flags & TRANSPORT_PUSH_ALL) {
680
- if (tags)
681
- die(_("options '%s' and '%s' cannot be used together"), "--all", "--tags");
682
if (argc >= 2)
683
die(_("--all can't be combined with refspecs"));
684
}
685
if (flags & TRANSPORT_PUSH_MIRROR) {
686
- if (tags)
687
- die(_("options '%s' and '%s' cannot be used together"), "--mirror", "--tags");
686
if (argc >= 2)
687
die(_("--mirror can't be combined with refspecs"));
688
}
691
- if ((flags & TRANSPORT_PUSH_ALL) && (flags & TRANSPORT_PUSH_MIRROR))
692
- die(_("options '%s' and '%s' cannot be used together"), "--all", "--mirror");
689
690
if (!is_empty_cas(&cas) && (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES))
691
cas.use_force_if_includes = 1;