Hi, this patch series introduces a new `--exists` mode to git-show-ref(1) to explicitly check for the existence of a reference, only. It tries to address a gap in our plumbing tools: while we have a plethora of tools to resolve revisions and thus also references, we do not have any tool that can generically check for the existence of both direct and symoblic references without resolving its contents. This series has been split out of my other patch series that refactors our test suite to reduce direct access to on-disk data structures. It is structured as follows: - Patches 1-8 refactor the code to stop relying on global variables, addressing some smaller issues that surface. Furthermore, the different modes that git-show-ref(1) has are made more explicit such that the command becomes more extensible. - Patch 9 ensures that the user does not request mutually exclusive modes. - Patch 10 updates the documentation to better reflect how the modes are to be used. - Patch 11 introduces the new `--exists` mode as well as a bunch of tests for it. - Patch 12 introduces two test helpers `test_ref_exists` and `test_ref_missing` and updates many of our tests to use those instead. I admittedly may have went a bit overboard with this series. But I had a hard time understanding git-show-ref(1) and how the global state affects the different modes. Patrick [1]: <cover.1697607222.git.ps@xxxxxx> Patrick Steinhardt (12): builtin/show-ref: convert pattern to a local variable builtin/show-ref: split up different subcommands builtin/show-ref: fix leaking string buffer builtin/show-ref: fix dead code when passing patterns builtin/show-ref: refactor `--exclude-existing` options builtin/show-ref: stop using global variable to count matches builtin/show-ref: stop using global vars for `show_one()` builtin/show-ref: refactor options for patterns subcommand builtin/show-ref: ensure mutual exclusiveness of subcommands builtin/show-ref: explicitly spell out different modes in synopsis builtin/show-ref: add new mode to check for reference existence t: use git-show-ref(1) to check for ref existence Documentation/git-show-ref.txt | 16 +- builtin/show-ref.c | 275 ++++++++++++++++++++++----------- t/t1403-show-ref.sh | 70 +++++++++ t/t1430-bad-ref-name.sh | 27 ++-- t/t3200-branch.sh | 33 ++-- t/t5521-pull-options.sh | 4 +- t/t5605-clone-local.sh | 2 +- t/test-lib-functions.sh | 55 +++++++ 8 files changed, 363 insertions(+), 119 deletions(-) base-commit: a9ecda2788e229afc9b611acaa26d0d9d4da53ed -- 2.42.0
Attachment:
signature.asc
Description: PGP signature