diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-05-03 20:34:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-03 20:34:49 +0100 |
commit | 4c53decce0448efa6da0cfc4939693cb4e378648 (patch) | |
tree | 8f545217fa3b87c7f7d64da99f71f4e07d01dd9d /repository.go | |
parent | 02856b824a05c18118c116af5b0e2bca1b3496b3 (diff) | |
parent | a4b11abc55bf88fbd07a00a5985a34750bee1d72 (diff) | |
download | go-git-4c53decce0448efa6da0cfc4939693cb4e378648.tar.gz |
Merge pull request #755 from AriehSchneier/fix-clone-branch
git: fix cloning with branch name
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) |