From 75032bbf57b9b6053942b4723e10a616dcba169f Mon Sep 17 00:00:00 2001 From: Kevin Burge Date: Tue, 12 Mar 2019 09:00:10 -0500 Subject: [PATCH] fix "reference delta not found" when cloning from aws codecommit The existing code does not handle the case where a ref delta refers to another deltified object. Once the "parent" was undeltified, not attempt was made to resolve references to that object's SHA1. This change simply checks to see if there is an ExternalRef to the object just resolved, and if so, replaces it and adopts its children. I'm not an expert in the bowels of git, but this fixed my inability to clone from codecommit. Signed-off-by: Kevin Burge --- plumbing/format/packfile/parser.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plumbing/format/packfile/parser.go b/plumbing/format/packfile/parser.go index 71cbba983..e65394bae 100644 --- a/plumbing/format/packfile/parser.go +++ b/plumbing/format/packfile/parser.go @@ -282,6 +282,18 @@ func (p *Parser) resolveDeltas() error { if _, err := p.resolveObject(child, content); err != nil { return err } + + extRef, ok := p.oiByHash[child.SHA1] + if ok && extRef.ExternalRef { + // replace parent placeholder + p.oiByHash[child.SHA1] = child + + // adopt children + child.Children = extRef.Children + for _, c := range child.Children { + c.Parent = child + } + } } // Remove the delta from the cache.