aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-05-08 11:30:11 +0200
committerGitHub <noreply@github.com>2017-05-08 11:30:11 +0200
commit7cd021554eb318165dd28988fe1675a5e5c32601 (patch)
tree729b4f61af22e540887d9f3cf57e4cdfe2a14151 /plumbing
parentced875aec7bef9113e1c37b1b811a59e17dbd138 (diff)
parent7b3ff5810ef994b468b0d7c993819aae563796df (diff)
downloadgo-git-7cd021554eb318165dd28988fe1675a5e5c32601.tar.gz
Merge pull request #374 from ajnavarro/fix/delta-encoder-big-deltas
format/packfile: fix bug when the delta depth is equals to 50
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/format/packfile/delta_selector.go5
-rw-r--r--plumbing/format/packfile/delta_selector_test.go5
2 files changed, 10 insertions, 0 deletions
diff --git a/plumbing/format/packfile/delta_selector.go b/plumbing/format/packfile/delta_selector.go
index a73a209..20c8cea 100644
--- a/plumbing/format/packfile/delta_selector.go
+++ b/plumbing/format/packfile/delta_selector.go
@@ -142,6 +142,11 @@ func (dw *deltaSelector) deltaSizeLimit(targetSize int64, baseDepth int,
d := int64(targetDepth)
n := targetSize
+ // If target depth is bigger than maxDepth, this delta is not suitable to be used.
+ if d >= maxDepth {
+ return 0
+ }
+
// If src is whole (depth=0) and base is near limit (depth=9/10)
// any delta using src can be 10x larger and still be better.
//
diff --git a/plumbing/format/packfile/delta_selector_test.go b/plumbing/format/packfile/delta_selector_test.go
index 9a8833f..cbbbc89 100644
--- a/plumbing/format/packfile/delta_selector_test.go
+++ b/plumbing/format/packfile/delta_selector_test.go
@@ -197,3 +197,8 @@ func (s *DeltaSelectorSuite) TestObjectsToPack(c *C) {
c.Assert(otp[2].IsDelta(), Equals, true)
c.Assert(otp[2].Depth, Equals, 2)
}
+
+func (s *DeltaSelectorSuite) TestMaxDepth(c *C) {
+ dsl := s.ds.deltaSizeLimit(0, 0, int(maxDepth), true)
+ c.Assert(dsl, Equals, int64(0))
+}