aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2023-12-14 14:37:02 +0100
committerJunio C Hamano <gitster@pobox.com>2023-12-14 09:25:26 -0800
commit668cdc043fe6f6d1fa2bf2b3f3c2375a20819e77 (patch)
treebb7d9f35543be78997bacb5b1397726c080b5a3f /t
parentwt-status: read HEAD and ORIG_HEAD via the refdb (diff)
downloadgit-668cdc043fe6f6d1fa2bf2b3f3c2375a20819e77.tar.gz
git-668cdc043fe6f6d1fa2bf2b3f3c2375a20819e77.zip
refs: propagate errno when reading special refs fails
Some refs in Git are more special than others due to reasons explained in the next commit. These refs are read via `refs_read_special_head()`, but this function doesn't behave the same as when we try to read a normal ref. Most importantly, we do not propagate `failure_errno` in the case where the reference does not exist, which is behaviour that we rely on in many parts of Git. Fix this bug by propagating errno when `strbuf_read_file()` fails. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1403-show-ref.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
index b50ae6fcf1..66e6e77fa9 100755
--- a/t/t1403-show-ref.sh
+++ b/t/t1403-show-ref.sh
@@ -266,4 +266,14 @@ test_expect_success '--exists with directory fails with generic error' '
test_cmp expect err
'
+test_expect_success '--exists with non-existent special ref' '
+ test_expect_code 2 git show-ref --exists FETCH_HEAD
+'
+
+test_expect_success '--exists with existing special ref' '
+ test_when_finished "rm .git/FETCH_HEAD" &&
+ git rev-parse HEAD >.git/FETCH_HEAD &&
+ git show-ref --exists FETCH_HEAD
+'
+
test_done