mbox series

[0/1] Fix error message in git-show-ref(1) --exists

Message ID 20240110141559.387815-1-toon@iotcl.com (mailing list archive)
Headers show
Series Fix error message in git-show-ref(1) --exists | expand

Message

Toon Claes Jan. 10, 2024, 2:15 p.m. UTC
References can validly contain forward slashes in their name. With the ref files
backend, these are stored as a directory tree. This means when you look up a
reference, you might find a directory where you expected a file.

This causes the option --exists, recently added to git-show-ref(1), to return
the following error:

    error: failed to look up reference: Is a directory

Other backends, like reftables, might store refs with forward slashes
differently. So they will not encounter the same error.

To make the error consistent across refs backend implementations, and to be more
clear to user, hide the error about having found a directory as a generic error:

    error: reference does not exist

Toon Claes (1):
  builtin/show-ref: treat directory directory as non-existing in
    --exists

 builtin/show-ref.c  | 2 +-
 t/t1403-show-ref.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)


base-commit: a54a84b333adbecf7bc4483c0e36ed5878cac17b
--
2.42.1