aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2024-02-07 16:44:35 +0000
committerJunio C Hamano <gitster@pobox.com>2024-02-07 09:12:47 -0800
commit1dbe40156307763255d96653cc853ef4ff841920 (patch)
treeb190d4904e85c0a8d4c983abd51c321089ba59ad /builtin
parent235986be822c9f8689be2e9a0b7804d0b1b6d821 (diff)
downloadgit-1dbe40156307763255d96653cc853ef4ff841920.tar.gz
show-ref --verify: accept pseudorefs
"git show-ref --verify" is useful for scripts that want to look up a fully qualified refname without falling back to the DWIM rules used by "git rev-parse" rules when the ref does not exist. Currently it will only accept "HEAD" or a refname beginning with "refs/". Running git show-ref --verify CHERRY_PICK_HEAD will always result in fatal: 'CHERRY_PICK_HEAD' - not a valid ref even when CHERRY_PICK_HEAD exists. By calling refname_is_safe() instead of comparing the refname to "HEAD" we can accept all one-level refs that contain only uppercase ascii letters and underscores. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/show-ref.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 79955c2856..1c15421e60 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -172,7 +172,7 @@ static int cmd_show_ref__verify(const struct show_one_options *show_one_opts,
while (*refs) {
struct object_id oid;
- if ((starts_with(*refs, "refs/") || !strcmp(*refs, "HEAD")) &&
+ if ((starts_with(*refs, "refs/") || refname_is_safe(*refs)) &&
!read_ref(*refs, &oid)) {
show_one(show_one_opts, *refs, &oid);
}