aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2022-01-08 14:22:48 +0100
committerGitHub <noreply@github.com>2022-01-08 14:22:48 +0100
commita5bbcd278ab1467bf9a8dfa615649b6c4d699119 (patch)
tree5fc41da16c024d40c33ebf2569e2c62717cb4a29 /plumbing/format
parentf0b111ab70e4e90013658b0835929b2083902017 (diff)
parentbf57a4c6a53423d92aeeadf1bc02877cc80459d4 (diff)
downloadgo-git-a5bbcd278ab1467bf9a8dfa615649b6c4d699119.tar.gz
pumbling: packfile, resolve external reference delta
fix: resolve external reference delta
Diffstat (limited to 'plumbing/format')
-rw-r--r--plumbing/format/packfile/parser.go11
-rw-r--r--plumbing/format/packfile/parser_test.go13
2 files changed, 24 insertions, 0 deletions
diff --git a/plumbing/format/packfile/parser.go b/plumbing/format/packfile/parser.go
index ee5c289..9ec838e 100644
--- a/plumbing/format/packfile/parser.go
+++ b/plumbing/format/packfile/parser.go
@@ -286,6 +286,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.
@@ -298,6 +299,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)
diff --git a/plumbing/format/packfile/parser_test.go b/plumbing/format/packfile/parser_test.go
index b0b4af8..09f3f97 100644
--- a/plumbing/format/packfile/parser_test.go
+++ b/plumbing/format/packfile/parser_test.go
@@ -132,6 +132,19 @@ func (s *ParserSuite) TestThinPack(c *C) {
}
+func (s *ParserSuite) TestResolveExternalRefsInThinPack(c *C) {
+ extRefsThinPack := fixtures.ByTag("codecommit").One()
+
+ scanner := packfile.NewScanner(extRefsThinPack.Packfile())
+
+ obs := new(testObserver)
+ parser, err := packfile.NewParser(scanner, obs)
+ c.Assert(err, IsNil)
+
+ _, err = parser.Parse()
+ c.Assert(err, IsNil)
+}
+
type observerObject struct {
hash string
otype plumbing.ObjectType