diff options
| author | 2025-11-20 08:00:00 +0800 | |
|---|---|---|
| committer | 2025-11-20 08:00:00 +0800 | |
| commit | a27bd4625f6e1f5153e5e654b09156cea48f82d2 (patch) | |
| tree | ba60075ebdda0b0238f02f52465ab5464541841f /refs.go | |
| parent | refs: ResolveRef and ResolveRefFully, no HEAD split (diff) | |
| signature | No signature | |
refs: Support resolving hashes as refs
Diffstat (limited to 'refs.go')
| -rw-r--r-- | refs.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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, |
