Skip to content

Commit 908fde1

Browse files
committed
Merge branch 'tc/show-ref-exists-fix' into maint-2.43
Update to a new feature recently added, "git show-ref --exists". * tc/show-ref-exists-fix: builtin/show-ref: treat directory as non-existing in --exists
2 parents 7adf215 + 0aabeaa commit 908fde1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builtin/show-ref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int cmd_show_ref__exists(const char **refs)
238238
if (refs_read_raw_ref(get_main_ref_store(the_repository), ref,
239239
&unused_oid, &unused_referent, &unused_type,
240240
&failure_errno)) {
241-
if (failure_errno == ENOENT) {
241+
if (failure_errno == ENOENT || failure_errno == EISDIR) {
242242
error(_("reference does not exist"));
243243
ret = 2;
244244
} else {

t/t1403-show-ref.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ test_expect_success '--exists with non-commit object' '
262262

263263
test_expect_success '--exists with directory fails with generic error' '
264264
cat >expect <<-EOF &&
265-
error: failed to look up reference: Is a directory
265+
error: reference does not exist
266266
EOF
267-
test_expect_code 1 git show-ref --exists refs/heads 2>err &&
267+
test_expect_code 2 git show-ref --exists refs/heads 2>err &&
268268
test_cmp expect err
269269
'
270270

0 commit comments

Comments
 (0)