From a27bd4625f6e1f5153e5e654b09156cea48f82d2 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 20 Nov 2025 08:00:00 +0800 Subject: refs: Support resolving hashes as refs --- refs.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'refs.go') diff --git a/refs.go b/refs.go index 258f06df..59621b40 100644 --- a/refs.go +++ b/refs.go @@ -156,6 +156,14 @@ func (repo *Repository) ResolveRef(path string) (Ref, error) { "HEAD", "ORIG_HEAD", "FETCH_HEAD", "MERGE_HEAD", "CHERRY_PICK_HEAD", "REVERT_HEAD", "REBASE_HEAD", "BISECT_HEAD", }, path) { + id, err := repo.ParseHash(path) + if err == nil { + return Ref{ + Kind: RefKindDetached, + Hash: id, + }, nil + } + // For now let's keep this to prevent e.g., random users from // specifying something crazy like objects/... or ./config. // There may be other legal pseudo-refs in the future, -- cgit v1.3.1-10-gc9f91