aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-04-11 19:08:53 +0100
committerGitHub <noreply@github.com>2023-04-11 19:08:53 +0100
commitce62f3e9ff86270538a514a68d3bd5563a733e3b (patch)
treebf1afc93f0245323589c5f8715718533c794b5b1 /plumbing
parent3f1cfde283c93f33218c807602e93d47f72f7b90 (diff)
parentcdd1e5562d10c6bb19f979ca32f3ae7ef646024f (diff)
downloadgo-git-ce62f3e9ff86270538a514a68d3bd5563a733e3b.tar.gz
Merge pull request #485 from ZauberNerd/fix-non-external-delta-ref
plumbing: resolve non-external delta references
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/format/packfile/parser.go9
-rw-r--r--plumbing/format/packfile/parser_test.go13
2 files changed, 22 insertions, 0 deletions
diff --git a/plumbing/format/packfile/parser.go b/plumbing/format/packfile/parser.go
index 522c146..6012b04 100644
--- a/plumbing/format/packfile/parser.go
+++ b/plumbing/format/packfile/parser.go
@@ -237,6 +237,15 @@ func (p *Parser) indexObjects() error {
return err
}
+ // Move children of placeholder parent into actual parent, in case this
+ // was a non-external delta reference.
+ if placeholder, ok := p.oiByHash[sha1]; ok {
+ ota.Children = placeholder.Children
+ for _, c := range ota.Children {
+ c.Parent = ota
+ }
+ }
+
ota.SHA1 = sha1
p.oiByHash[ota.SHA1] = ota
}
diff --git a/plumbing/format/packfile/parser_test.go b/plumbing/format/packfile/parser_test.go
index 651d05f..b8d080f 100644
--- a/plumbing/format/packfile/parser_test.go
+++ b/plumbing/format/packfile/parser_test.go
@@ -147,6 +147,19 @@ func (s *ParserSuite) TestResolveExternalRefsInThinPack(c *C) {
c.Assert(err, IsNil)
}
+func (s *ParserSuite) TestResolveExternalRefs(c *C) {
+ extRefsThinPack := fixtures.ByTag("delta-before-base").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