Skip to content

Commit b3bf470

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 564d025 commit b3bf470

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

builtin/push.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,10 @@ int cmd_push(int argc, const char **argv, const char *prefix)
639639
: &push_options_config);
640640
set_push_cert_flags(&flags, push_cert);
641641

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");
644646
if (deleterefs && argc < 2)
645647
die(_("--delete doesn't make sense without any refs"));
646648

@@ -677,19 +679,13 @@ int cmd_push(int argc, const char **argv, const char *prefix)
677679
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
678680

679681
if (flags & TRANSPORT_PUSH_ALL) {
680-
if (tags)
681-
die(_("options '%s' and '%s' cannot be used together"), "--all", "--tags");
682682
if (argc >= 2)
683683
die(_("--all can't be combined with refspecs"));
684684
}
685685
if (flags & TRANSPORT_PUSH_MIRROR) {
686-
if (tags)
687-
die(_("options '%s' and '%s' cannot be used together"), "--mirror", "--tags");
688686
if (argc >= 2)
689687
die(_("--mirror can't be combined with refspecs"));
690688
}
691-
if ((flags & TRANSPORT_PUSH_ALL) && (flags & TRANSPORT_PUSH_MIRROR))
692-
die(_("options '%s' and '%s' cannot be used together"), "--all", "--mirror");
693689

694690
if (!is_empty_cas(&cas) && (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES))
695691
cas.use_force_if_includes = 1;

0 commit comments

Comments
 (0)