aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--builtin/show-ref.c4
-rwxr-xr-xt/t1403-show-ref.sh9
2 files changed, 13 insertions, 0 deletions
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 36ac10551d..6685495dd2 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -275,6 +275,10 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, show_ref_options,
show_ref_usage, 0);
+ if ((!!exclude_existing_opts.enabled + !!verify) > 1)
+ die(_("only one of '%s' or '%s' can be given"),
+ "--exclude-existing", "--verify");
+
if (exclude_existing_opts.enabled)
return cmd_show_ref__exclude_existing(&exclude_existing_opts);
else if (verify)
diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
index 9252a581ab..f1e0388324 100755
--- a/t/t1403-show-ref.sh
+++ b/t/t1403-show-ref.sh
@@ -196,4 +196,13 @@ test_expect_success 'show-ref --verify with dangling ref' '
)
'
+test_expect_success 'show-ref sub-modes are mutually exclusive' '
+ cat >expect <<-EOF &&
+ fatal: only one of ${SQ}--exclude-existing${SQ} or ${SQ}--verify${SQ} can be given
+ EOF
+
+ test_must_fail git show-ref --verify --exclude-existing 2>err &&
+ test_cmp expect err
+'
+
test_done