diff options
| author | Patrick Steinhardt <ps@pks.im> | 2023-10-31 09:16:46 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-11-01 12:09:00 +0900 |
| commit | 199970e72fbfa9c858fdf2eec63bf53704bc01c6 (patch) | |
| tree | 2cf402ef6cea5ce0567be82c244d35b479287c0b /t | |
| parent | builtin/show-ref: refactor options for patterns subcommand (diff) | |
| download | git-199970e72fbfa9c858fdf2eec63bf53704bc01c6.tar.gz git-199970e72fbfa9c858fdf2eec63bf53704bc01c6.zip | |
builtin/show-ref: ensure mutual exclusiveness of subcommands
The git-show-ref(1) command has three different modes, of which one is
implicit and the other two can be chosen explicitly by passing a flag.
But while these modes are standalone and cause us to execute completely
separate code paths, we gladly accept the case where a user asks for
both `--exclude-existing` and `--verify` at the same time even though it
is not obvious what will happen. Spoiler: we ignore `--verify` and
execute the `--exclude-existing` mode.
Let's explicitly detect this invalid usage and die in case both modes
were requested.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
| -rwxr-xr-x | t/t1403-show-ref.sh | 9 |
1 files changed, 9 insertions, 0 deletions
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 |
