@@ -146,31 +146,32 @@ func (s *DeltaSelectorSuite) createTestObjects() {
146
146
func (s * DeltaSelectorSuite ) TestObjectsToPack (c * C ) {
147
147
// Different type
148
148
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 )
150
151
c .Assert (err , IsNil )
151
152
c .Assert (len (otp ), Equals , 2 )
152
153
c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["base" ]])
153
154
c .Assert (otp [1 ].Object , Equals , s .store .Objects [s .hashes ["treeType" ]])
154
155
155
156
// Size radically different
156
157
hashes = []plumbing.Hash {s .hashes ["bigBase" ], s .hashes ["target" ]}
157
- otp , err = s .ds .ObjectsToPack (hashes )
158
+ otp , err = s .ds .ObjectsToPack (hashes , deltaWindowSize )
158
159
c .Assert (err , IsNil )
159
160
c .Assert (len (otp ), Equals , 2 )
160
161
c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["bigBase" ]])
161
162
c .Assert (otp [1 ].Object , Equals , s .store .Objects [s .hashes ["target" ]])
162
163
163
164
// Delta Size Limit with no best delta yet
164
165
hashes = []plumbing.Hash {s .hashes ["smallBase" ], s .hashes ["smallTarget" ]}
165
- otp , err = s .ds .ObjectsToPack (hashes )
166
+ otp , err = s .ds .ObjectsToPack (hashes , deltaWindowSize )
166
167
c .Assert (err , IsNil )
167
168
c .Assert (len (otp ), Equals , 2 )
168
169
c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["smallBase" ]])
169
170
c .Assert (otp [1 ].Object , Equals , s .store .Objects [s .hashes ["smallTarget" ]])
170
171
171
172
// It will create the delta
172
173
hashes = []plumbing.Hash {s .hashes ["base" ], s .hashes ["target" ]}
173
- otp , err = s .ds .ObjectsToPack (hashes )
174
+ otp , err = s .ds .ObjectsToPack (hashes , deltaWindowSize )
174
175
c .Assert (err , IsNil )
175
176
c .Assert (len (otp ), Equals , 2 )
176
177
c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["target" ]])
@@ -185,7 +186,7 @@ func (s *DeltaSelectorSuite) TestObjectsToPack(c *C) {
185
186
s .hashes ["o2" ],
186
187
s .hashes ["o3" ],
187
188
}
188
- otp , err = s .ds .ObjectsToPack (hashes )
189
+ otp , err = s .ds .ObjectsToPack (hashes , deltaWindowSize )
189
190
c .Assert (err , IsNil )
190
191
c .Assert (len (otp ), Equals , 3 )
191
192
c .Assert (otp [0 ].Object , Equals , s .store .Objects [s .hashes ["o1" ]])
@@ -201,20 +202,32 @@ func (s *DeltaSelectorSuite) TestObjectsToPack(c *C) {
201
202
// a delta.
202
203
hashes = make ([]plumbing.Hash , 0 , deltaWindowSize + 2 )
203
204
hashes = append (hashes , s .hashes ["base" ])
204
- for i := 0 ; i < deltaWindowSize ; i ++ {
205
+ for i := uint ( 0 ) ; i < deltaWindowSize ; i ++ {
205
206
hashes = append (hashes , s .hashes ["smallTarget" ])
206
207
}
207
208
hashes = append (hashes , s .hashes ["target" ])
208
209
209
210
// Don't sort so we can easily check the sliding window without
210
211
// creating a bunch of new objects.
211
- otp , err = s .ds .objectsToPack (hashes )
212
+ otp , err = s .ds .objectsToPack (hashes , deltaWindowSize )
212
213
c .Assert (err , IsNil )
213
- err = s .ds .walk (otp )
214
+ err = s .ds .walk (otp , deltaWindowSize )
214
215
c .Assert (err , IsNil )
215
- c .Assert (len (otp ), Equals , deltaWindowSize + 2 )
216
+ c .Assert (len (otp ), Equals , int ( deltaWindowSize ) + 2 )
216
217
targetIdx := len (otp ) - 1
217
218
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 )
218
231
}
219
232
220
233
func (s * DeltaSelectorSuite ) TestMaxDepth (c * C ) {
0 commit comments