]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/refs: add 'exists' subcommand
authorMeet Soni <meetsoni3017@gmail.com>
Tue, 26 Aug 2025 06:41:07 +0000 (12:11 +0530)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Sep 2025 16:58:35 +0000 (09:58 -0700)
commit0f0a8a11c00295ed30b02cc721b0994900c6a3d3
treeb853fe5407422f87325aaee3ceef1528e5865182
parent1fa68948c3d76328236cac73d2adf33c905bd8e3
builtin/refs: add 'exists' subcommand

As part of the ongoing effort to consolidate reference handling,
introduce a new `exists` subcommand. This command provides the same
functionality and exit-code behavior as `git show-ref --exists`, serving
as its modern replacement.

The logic for `show-ref --exists` is minimal. Rather than creating a
shared helper function which would be overkill for ~20 lines of code,
its implementation is intentionally duplicated here. This contrasts with
`git refs list`, where sharing the larger implementation of
`for-each-ref` was necessary.

Documentation for the new subcommand is also added to the `git-refs(1)`
man page.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-refs.adoc
builtin/refs.c