@@ -146,31 +146,32 @@ func (s *DeltaSelectorSuite) createTestObjects() {
146146func (s * DeltaSelectorSuite ) TestObjectsToPack (c * C ) {
147147 // Different type
148148 hashes := []plumbing.Hash {s .hashes ["base" ], s .hashes ["treeType" ]}
149- otp , err := s .ds .ObjectsToPack (hashes )
149+ deltaWindowSize := uint (10 )
150+ otp , err := s .ds .ObjectsToPack (hashes , deltaWindowSize )
150151 c .Assert (err , IsNil )
151152 c .Assert (len (otp ), Equals , 2 )
152153 c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["base" ]])
153154 c .Assert (otp [1 ].Object , Equals , s .store .Objects [s .hashes ["treeType" ]])
154155
155156 // Size radically different
156157 hashes = []plumbing.Hash {s .hashes ["bigBase" ], s .hashes ["target" ]}
157- otp , err = s .ds .ObjectsToPack (hashes )
158+ otp , err = s .ds .ObjectsToPack (hashes , deltaWindowSize )
158159 c .Assert (err , IsNil )
159160 c .Assert (len (otp ), Equals , 2 )
160161 c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["bigBase" ]])
161162 c .Assert (otp [1 ].Object , Equals , s .store .Objects [s .hashes ["target" ]])
162163
163164 // Delta Size Limit with no best delta yet
164165 hashes = []plumbing.Hash {s .hashes ["smallBase" ], s .hashes ["smallTarget" ]}
165- otp , err = s .ds .ObjectsToPack (hashes )
166+ otp , err = s .ds .ObjectsToPack (hashes , deltaWindowSize )
166167 c .Assert (err , IsNil )
167168 c .Assert (len (otp ), Equals , 2 )
168169 c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["smallBase" ]])
169170 c .Assert (otp [1 ].Object , Equals , s .store .Objects [s .hashes ["smallTarget" ]])
170171
171172 // It will create the delta
172173 hashes = []plumbing.Hash {s .hashes ["base" ], s .hashes ["target" ]}
173- otp , err = s .ds .ObjectsToPack (hashes )
174+ otp , err = s .ds .ObjectsToPack (hashes , deltaWindowSize )
174175 c .Assert (err , IsNil )
175176 c .Assert (len (otp ), Equals , 2 )
176177 c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["target" ]])
@@ -185,7 +186,7 @@ func (s *DeltaSelectorSuite) TestObjectsToPack(c *C) {
185186 s .hashes ["o2" ],
186187 s .hashes ["o3" ],
187188 }
188- otp , err = s .ds .ObjectsToPack (hashes )
189+ otp , err = s .ds .ObjectsToPack (hashes , deltaWindowSize )
189190 c .Assert (err , IsNil )
190191 c .Assert (len (otp ), Equals , 3 )
191192 c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["o1" ]])
@@ -201,20 +202,32 @@ func (s *DeltaSelectorSuite) TestObjectsToPack(c *C) {
201202 // a delta.
202203 hashes = make ([]plumbing.Hash , 0 , deltaWindowSize + 2 )
203204 hashes = append (hashes , s .hashes ["base" ])
204- for i := 0 ; i < deltaWindowSize ; i ++ {
205+ for i := uint ( 0 ) ; i < deltaWindowSize ; i ++ {
205206 hashes = append (hashes , s .hashes ["smallTarget" ])
206207 }
207208 hashes = append (hashes , s .hashes ["target" ])
208209
209210 // Don't sort so we can easily check the sliding window without
210211 // creating a bunch of new objects.
211- otp , err = s .ds .objectsToPack (hashes )
212+ otp , err = s .ds .objectsToPack (hashes , deltaWindowSize )
212213 c .Assert (err , IsNil )
213- err = s .ds .walk (otp )
214+ err = s .ds .walk (otp , deltaWindowSize )
214215 c .Assert (err , IsNil )
215- c .Assert (len (otp ), Equals , deltaWindowSize + 2 )
216+ c .Assert (len (otp ), Equals , int ( deltaWindowSize ) + 2 )
216217 targetIdx := len (otp ) - 1
217218 c .Assert (otp [targetIdx ].IsDelta (), Equals , false )
219+
220+ // Check that no deltas are created, and the objects are unsorted,
221+ // if compression is off.
222+ hashes = []plumbing.Hash {s .hashes ["base" ], s .hashes ["target" ]}
223+ otp , err = s .ds .ObjectsToPack (hashes , 0 )
224+ c .Assert (err , IsNil )
225+ c .Assert (len (otp ), Equals , 2 )
226+ c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["base" ]])
227+ c .Assert (otp [0 ].IsDelta (), Equals , false )
228+ c .Assert (otp [1 ].Original , Equals , s .store .Objects [s .hashes ["target" ]])
229+ c .Assert (otp [1 ].IsDelta (), Equals , false )
230+ c .Assert (otp [1 ].Depth , Equals , 0 )
218231}
219232
220233func (s * DeltaSelectorSuite ) TestMaxDepth (c * C ) {
0 commit comments