From 65a5c716353f81b20c70f4a2c6560590d9472b6e Mon Sep 17 00:00:00 2001 From: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> Date: Thu, 25 May 2023 08:56:17 +1000 Subject: git: enable fetch with unqualified references Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> --- plumbing/reference.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'plumbing') diff --git a/plumbing/reference.go b/plumbing/reference.go index aeb4227..5a67f69 100644 --- a/plumbing/reference.go +++ b/plumbing/reference.go @@ -15,10 +15,11 @@ const ( symrefPrefix = "ref: " ) -// RefRevParseRules are a set of rules to parse references into short names. -// These are the same rules as used by git in shorten_unambiguous_ref. +// RefRevParseRules are a set of rules to parse references into short names, or expand into a full reference. +// These are the same rules as used by git in shorten_unambiguous_ref and expand_ref. // See: https://github.com/git/git/blob/e0aaa1b6532cfce93d87af9bc813fb2e7a7ce9d7/refs.c#L417 var RefRevParseRules = []string{ + "%s", "refs/%s", "refs/tags/%s", "refs/heads/%s", @@ -113,7 +114,7 @@ func (r ReferenceName) String() string { func (r ReferenceName) Short() string { s := string(r) res := s - for _, format := range RefRevParseRules { + for _, format := range RefRevParseRules[1:] { _, err := fmt.Sscanf(s, format, &res) if err == nil { continue -- cgit