diff options
author | Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> | 2023-05-03 14:01:24 +1000 |
---|---|---|
committer | Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> | 2023-05-03 14:01:24 +1000 |
commit | a4b11abc55bf88fbd07a00a5985a34750bee1d72 (patch) | |
tree | 167143e089189eac69cdcaadccbed7b400419dc5 /repository.go | |
parent | 0542a302c2be7ed7de276411f7e20b87309734b9 (diff) | |
download | go-git-a4b11abc55bf88fbd07a00a5985a34750bee1d72.tar.gz |
git: fix cloning with branch name
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
Diffstat (limited to 'repository.go')
-rw-r--r-- | repository.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/repository.go b/repository.go index e009c5d..be5f140 100644 --- a/repository.go +++ b/repository.go @@ -1012,9 +1012,21 @@ func (r *Repository) fetchAndUpdateReferences( return nil, err } - resolvedRef, err := storer.ResolveReference(remoteRefs, ref) + var resolvedRef *plumbing.Reference + // return error from checking the raw ref passed in + var rawRefError error + for _, rule := range append([]string{"%s"}, plumbing.RefRevParseRules...) { + resolvedRef, err = storer.ResolveReference(remoteRefs, plumbing.ReferenceName(fmt.Sprintf(rule, ref))) + + if err == nil { + break + } else if rawRefError == nil { + rawRefError = err + } + } + if err != nil { - return nil, err + return nil, rawRefError } refsUpdated, err := r.updateReferences(remote.c.Fetch, resolvedRef) |