Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 7cd0215

Browse files
authored
Merge pull request #374 from ajnavarro/fix/delta-encoder-big-deltas
format/packfile: fix bug when the delta depth is equals to 50
2 parents ced875a + 7b3ff58 commit 7cd0215

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

plumbing/format/packfile/delta_selector.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ func (dw *deltaSelector) deltaSizeLimit(targetSize int64, baseDepth int,
142142
d := int64(targetDepth)
143143
n := targetSize
144144

145+
// If target depth is bigger than maxDepth, this delta is not suitable to be used.
146+
if d >= maxDepth {
147+
return 0
148+
}
149+
145150
// If src is whole (depth=0) and base is near limit (depth=9/10)
146151
// any delta using src can be 10x larger and still be better.
147152
//

plumbing/format/packfile/delta_selector_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,8 @@ func (s *DeltaSelectorSuite) TestObjectsToPack(c *C) {
197197
c.Assert(otp[2].IsDelta(), Equals, true)
198198
c.Assert(otp[2].Depth, Equals, 2)
199199
}
200+
201+
func (s *DeltaSelectorSuite) TestMaxDepth(c *C) {
202+
dsl := s.ds.deltaSizeLimit(0, 0, int(maxDepth), true)
203+
c.Assert(dsl, Equals, int64(0))
204+
}

0 commit comments

Comments
 (0)