Skip to content

Commit

Permalink
Merge pull request #485 from ZauberNerd/fix-non-external-delta-ref
Browse files Browse the repository at this point in the history
plumbing: resolve non-external delta references
  • Loading branch information
pjbgf committed Apr 11, 2023
2 parents 3f1cfde + cdd1e55 commit ce62f3e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/gliderlabs/ssh v0.3.5
github.com/go-git/gcfg v1.5.0
github.com/go-git/go-billy/v5 v5.4.1
github.com/go-git/go-git-fixtures/v4 v4.3.1
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f
github.com/google/go-cmp v0.5.9
github.com/imdario/mergo v0.3.13
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4u
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4=
github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg=
github.com/go-git/go-git-fixtures/v4 v4.3.1 h1:y5z6dd3qi8Hl+stezc8p3JxDkoTRqMAlKnXHuzrfjTQ=
github.com/go-git/go-git-fixtures/v4 v4.3.1/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
Expand Down
9 changes: 9 additions & 0 deletions plumbing/format/packfile/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
13 changes: 13 additions & 0 deletions plumbing/format/packfile/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ce62f3e

Please sign in to comment.