summaryrefslogtreecommitdiff
path: root/t/t9133-git-svn-nested-git-repo.sh
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2023-10-31 09:16:54 +0100
committerJunio C Hamano <gitster@pobox.com>2023-11-01 12:09:01 +0900
commit9080a7f1782b55ee146dd7f9b4f464fe5ea8747a (patch)
tree7dd1a65d3f82d5e9ea5f60f45d801ed01bba1a75 /t/t9133-git-svn-nested-git-repo.sh
parent1307d5e86fc7ea6f4352a70c24c6277a2f9939a3 (diff)
builtin/show-ref: add new mode to check for reference existence
While we have multiple ways to show the value of a given reference, we do not have any way to check whether a reference exists at all. While commands like git-rev-parse(1) or git-show-ref(1) can be used to check for reference existence in case the reference resolves to something sane, neither of them can be used to check for existence in some other scenarios where the reference does not resolve cleanly: - References which have an invalid name cannot be resolved. - References to nonexistent objects cannot be resolved. - Dangling symrefs can be resolved via git-symbolic-ref(1), but this requires the caller to special case existence checks depending on whether or not a reference is symbolic or direct. Furthermore, git-rev-list(1) and other commands do not let the caller distinguish easily between an actually missing reference and a generic error. Taken together, this seems like sufficient motivation to introduce a separate plumbing command to explicitly check for the existence of a reference without trying to resolve its contents. This new command comes in the form of `git show-ref --exists`. This new mode will exit successfully when the reference exists, with a specific exit code of 2 when it does not exist, or with 1 when there has been a generic error. Note that the only way to properly implement this command is by using the internal `refs_read_raw_ref()` function. While the public function `refs_resolve_ref_unsafe()` can be made to behave in the same way by passing various flags, it does not provide any way to obtain the errno with which the reference backend failed when reading the reference. As such, it becomes impossible for us to distinguish generic errors from the explicit case where the reference wasn't found. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9133-git-svn-nested-git-repo.sh')
0 files changed, 0 insertions, 0 deletions