-
Notifications
You must be signed in to change notification settings - Fork 540
Clone fails with "reference not found" error #785
Comments
I was looking into this and it seems that it is trying to find the HEAD reference for this repository. The HEAD reference is not getting set because the call to
We still do get a HEAD reference though. Should we set the HEAD reference despite not having the symref capability? |
Would that have any side-effects? This is all rather over my HEAD 😉 |
So instead of func addSymbolicRefs(s storer.ReferenceStorer, ar *AdvRefs) error {
for _, c := range []capability.Capability{capability.SymRef, capability.OldRef} {
if !supports(ar, c) {
continue
}
for _, symref := range ar.Capabilities.Get(c) {
chunks := strings.Split(symref, ":")
if len(chunks) != 2 {
err := fmt.Errorf("bad number of `:` in symref value (%q)", symref)
return plumbing.NewUnexpectedError(err)
}
name := plumbing.ReferenceName(chunks[0])
target := plumbing.ReferenceName(chunks[1])
ref := plumbing.NewSymbolicReference(name, target)
if err := s.SetReference(ref); err != nil {
return nil
}
}
}
return nil
}
func supports(ar *AdvRefs, c capability.Capability) bool {
return ar.Capabilities.Supports(c)
} ... this seems to work, but I have very little knowledge of git internals, so this may well be broken. |
Yeah, this is a bit over my head too 😅 |
Well having a hack like this unblocks my immediate problem, so I'm happy to wait until a git guru floats by. |
Here's another one that doesn't work (same error): https://code.googlesource.com/google-api-go-client
|
OK I got it working by hardcoding func addSymbolicRefs(s storer.ReferenceStorer, ar *AdvRefs) error {
var found bool
for _, c := range []capability.Capability{capability.SymRef, capability.OldRef} {
if !supports(ar, c) {
continue
}
for _, symref := range ar.Capabilities.Get(c) {
chunks := strings.Split(symref, ":")
if len(chunks) != 2 {
err := fmt.Errorf("bad number of `:` in symref value (%q)", symref)
return plumbing.NewUnexpectedError(err)
}
name := plumbing.ReferenceName(chunks[0])
target := plumbing.ReferenceName(chunks[1])
ref := plumbing.NewSymbolicReference(name, target)
if err := s.SetReference(ref); err != nil {
return nil
}
found = true
}
}
if !found {
ref := plumbing.NewSymbolicReference("HEAD", "refs/heads/master")
if err := s.SetReference(ref); err != nil {
return nil
}
}
return nil
}
func supports(ar *AdvRefs, c capability.Capability) bool {
return ar.Capabilities.Supports(c)
} |
Cloning the repo
https://gopkg.in/src-d/go-billy.v4
works in command linegit
:... but fails with
go-git
:Output:
The text was updated successfully, but these errors were encountered: