Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pumbling: packfile, resolve external reference delta #392

Merged
merged 8 commits into from Jan 8, 2022
11 changes: 11 additions & 0 deletions plumbing/format/packfile/parser.go
Expand Up @@ -287,6 +287,7 @@ func (p *Parser) resolveDeltas() error {
if err := p.resolveObject(stdioutil.Discard, child, content); err != nil {
return err
}
p.resolveExternalRef(child)
}

// Remove the delta from the cache.
Expand All @@ -299,6 +300,16 @@ func (p *Parser) resolveDeltas() error {
return nil
}

func (p *Parser) resolveExternalRef(o *objectInfo) {
if ref, ok := p.oiByHash[o.SHA1]; ok && ref.ExternalRef {
p.oiByHash[o.SHA1] = o
o.Children = ref.Children
for _, c := range o.Children {
c.Parent = o
}
}
}

func (p *Parser) get(o *objectInfo, buf *bytes.Buffer) (err error) {
if !o.ExternalRef { // skip cache check for placeholder parents
b, ok := p.cache.Get(o.Offset)
Expand Down