Merge branch 'rs/show-ref-incompatible-options'
Code clean-up for sanity checking of command line options for "git show-ref". * rs/show-ref-incompatible-options: show-ref: use die_for_incompatible_opt3()
This commit is contained in:
@ -315,9 +315,9 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
|
|||||||
argc = parse_options(argc, argv, prefix, show_ref_options,
|
argc = parse_options(argc, argv, prefix, show_ref_options,
|
||||||
show_ref_usage, 0);
|
show_ref_usage, 0);
|
||||||
|
|
||||||
if ((!!exclude_existing_opts.enabled + !!verify + !!exists) > 1)
|
die_for_incompatible_opt3(exclude_existing_opts.enabled, "--exclude-existing",
|
||||||
die(_("only one of '%s', '%s' or '%s' can be given"),
|
verify, "--verify",
|
||||||
"--exclude-existing", "--verify", "--exists");
|
exists, "--exists");
|
||||||
|
|
||||||
if (exclude_existing_opts.enabled)
|
if (exclude_existing_opts.enabled)
|
||||||
return cmd_show_ref__exclude_existing(&exclude_existing_opts);
|
return cmd_show_ref__exclude_existing(&exclude_existing_opts);
|
||||||
|
@ -197,18 +197,20 @@ test_expect_success 'show-ref --verify with dangling ref' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'show-ref sub-modes are mutually exclusive' '
|
test_expect_success 'show-ref sub-modes are mutually exclusive' '
|
||||||
cat >expect <<-EOF &&
|
|
||||||
fatal: only one of ${SQ}--exclude-existing${SQ}, ${SQ}--verify${SQ} or ${SQ}--exists${SQ} can be given
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_must_fail git show-ref --verify --exclude-existing 2>err &&
|
test_must_fail git show-ref --verify --exclude-existing 2>err &&
|
||||||
test_cmp expect err &&
|
grep "verify" err &&
|
||||||
|
grep "exclude-existing" err &&
|
||||||
|
grep "cannot be used together" err &&
|
||||||
|
|
||||||
test_must_fail git show-ref --verify --exists 2>err &&
|
test_must_fail git show-ref --verify --exists 2>err &&
|
||||||
test_cmp expect err &&
|
grep "verify" err &&
|
||||||
|
grep "exists" err &&
|
||||||
|
grep "cannot be used together" err &&
|
||||||
|
|
||||||
test_must_fail git show-ref --exclude-existing --exists 2>err &&
|
test_must_fail git show-ref --exclude-existing --exists 2>err &&
|
||||||
test_cmp expect err
|
grep "exclude-existing" err &&
|
||||||
|
grep "exists" err &&
|
||||||
|
grep "cannot be used together" err
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--exists with existing reference' '
|
test_expect_success '--exists with existing reference' '
|
||||||
|
Reference in New Issue
Block a user