aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/git-refs.adoc
diff options
context:
space:
mode:
authorMeet Soni <meetsoni3017@gmail.com>2025-08-26 12:11:07 +0530
committerJunio C Hamano <gitster@pobox.com>2025-09-02 09:58:35 -0700
commit0f0a8a11c00295ed30b02cc721b0994900c6a3d3 (patch)
treeb853fe5407422f87325aaee3ceef1528e5865182 /Documentation/git-refs.adoc
parent1fa68948c3d76328236cac73d2adf33c905bd8e3 (diff)
downloadgit-0f0a8a11c00295ed30b02cc721b0994900c6a3d3.tar.gz
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>
Diffstat (limited to 'Documentation/git-refs.adoc')
-rw-r--r--Documentation/git-refs.adoc7
1 files changed, 7 insertions, 0 deletions
diff --git a/Documentation/git-refs.adoc b/Documentation/git-refs.adoc
index e608980711..5d2032b318 100644
--- a/Documentation/git-refs.adoc
+++ b/Documentation/git-refs.adoc
@@ -18,6 +18,7 @@ git refs list [--count=<count>] [--shell|--perl|--python|--tcl]
[--contains[=<object>]] [--no-contains[=<object>]]
[(--exclude=<pattern>)...] [--start-after=<marker>]
[ --stdin | <pattern>... ]
+git refs exists <ref>
DESCRIPTION
-----------
@@ -38,6 +39,12 @@ list::
formatting, and sorting. This subcommand is an alias for
linkgit:git-for-each-ref[1] and offers identical functionality.
+exists::
+ Check whether the given reference exists. Returns an exit code of 0 if
+ it does, 2 if it is missing, and 1 in case looking up the reference
+ failed with an error other than the reference being missing. This does
+ not verify whether the reference resolves to an actual object.
+
OPTIONS
-------