@@ -229,9 +229,9 @@ static int splice_tree(const unsigned char *hash1,
229
229
* other hand, it could cover tree one and we might need to pick a
230
230
* subtree of it.
231
231
*/
232
- void shift_tree (const unsigned char * hash1 ,
233
- const unsigned char * hash2 ,
234
- unsigned char * shifted ,
232
+ void shift_tree (const struct object_id * hash1 ,
233
+ const struct object_id * hash2 ,
234
+ struct object_id * shifted ,
235
235
int depth_limit )
236
236
{
237
237
char * add_prefix ;
@@ -245,24 +245,24 @@ void shift_tree(const unsigned char *hash1,
245
245
if (!depth_limit )
246
246
depth_limit = 2 ;
247
247
248
- add_score = del_score = score_trees (hash1 , hash2 );
248
+ add_score = del_score = score_trees (hash1 -> hash , hash2 -> hash );
249
249
add_prefix = xcalloc (1 , 1 );
250
250
del_prefix = xcalloc (1 , 1 );
251
251
252
252
/*
253
253
* See if one's subtree resembles two; if so we need to prefix
254
254
* two with a few fake trees to match the prefix.
255
255
*/
256
- match_trees (hash1 , hash2 , & add_score , & add_prefix , "" , depth_limit );
256
+ match_trees (hash1 -> hash , hash2 -> hash , & add_score , & add_prefix , "" , depth_limit );
257
257
258
258
/*
259
259
* See if two's subtree resembles one; if so we need to
260
260
* pick only subtree of two.
261
261
*/
262
- match_trees (hash2 , hash1 , & del_score , & del_prefix , "" , depth_limit );
262
+ match_trees (hash2 -> hash , hash1 -> hash , & del_score , & del_prefix , "" , depth_limit );
263
263
264
264
/* Assume we do not have to do any shifting */
265
- hashcpy (shifted , hash2 );
265
+ oidcpy (shifted , hash2 );
266
266
267
267
if (add_score < del_score ) {
268
268
/* We need to pick a subtree of two */
@@ -271,61 +271,61 @@ void shift_tree(const unsigned char *hash1,
271
271
if (!* del_prefix )
272
272
return ;
273
273
274
- if (get_tree_entry (hash2 , del_prefix , shifted , & mode ))
274
+ if (get_tree_entry (hash2 -> hash , del_prefix , shifted -> hash , & mode ))
275
275
die ("cannot find path %s in tree %s" ,
276
- del_prefix , sha1_to_hex (hash2 ));
276
+ del_prefix , oid_to_hex (hash2 ));
277
277
return ;
278
278
}
279
279
280
280
if (!* add_prefix )
281
281
return ;
282
282
283
- splice_tree (hash1 , add_prefix , hash2 , shifted );
283
+ splice_tree (hash1 -> hash , add_prefix , hash2 -> hash , shifted -> hash );
284
284
}
285
285
286
286
/*
287
287
* The user says the trees will be shifted by this much.
288
288
* Unfortunately we cannot fundamentally tell which one to
289
289
* be prefixed, as recursive merge can work in either direction.
290
290
*/
291
- void shift_tree_by (const unsigned char * hash1 ,
292
- const unsigned char * hash2 ,
293
- unsigned char * shifted ,
291
+ void shift_tree_by (const struct object_id * hash1 ,
292
+ const struct object_id * hash2 ,
293
+ struct object_id * shifted ,
294
294
const char * shift_prefix )
295
295
{
296
- unsigned char sub1 [ 20 ] , sub2 [ 20 ] ;
296
+ struct object_id sub1 , sub2 ;
297
297
unsigned mode1 , mode2 ;
298
298
unsigned candidate = 0 ;
299
299
300
300
/* Can hash2 be a tree at shift_prefix in tree hash1? */
301
- if (!get_tree_entry (hash1 , shift_prefix , sub1 , & mode1 ) &&
301
+ if (!get_tree_entry (hash1 -> hash , shift_prefix , sub1 . hash , & mode1 ) &&
302
302
S_ISDIR (mode1 ))
303
303
candidate |= 1 ;
304
304
305
305
/* Can hash1 be a tree at shift_prefix in tree hash2? */
306
- if (!get_tree_entry (hash2 , shift_prefix , sub2 , & mode2 ) &&
306
+ if (!get_tree_entry (hash2 -> hash , shift_prefix , sub2 . hash , & mode2 ) &&
307
307
S_ISDIR (mode2 ))
308
308
candidate |= 2 ;
309
309
310
310
if (candidate == 3 ) {
311
311
/* Both are plausible -- we need to evaluate the score */
312
- int best_score = score_trees (hash1 , hash2 );
312
+ int best_score = score_trees (hash1 -> hash , hash2 -> hash );
313
313
int score ;
314
314
315
315
candidate = 0 ;
316
- score = score_trees (sub1 , hash2 );
316
+ score = score_trees (sub1 . hash , hash2 -> hash );
317
317
if (score > best_score ) {
318
318
candidate = 1 ;
319
319
best_score = score ;
320
320
}
321
- score = score_trees (sub2 , hash1 );
321
+ score = score_trees (sub2 . hash , hash1 -> hash );
322
322
if (score > best_score )
323
323
candidate = 2 ;
324
324
}
325
325
326
326
if (!candidate ) {
327
327
/* Neither is plausible -- do not shift */
328
- hashcpy (shifted , hash2 );
328
+ oidcpy (shifted , hash2 );
329
329
return ;
330
330
}
331
331
@@ -334,11 +334,11 @@ void shift_tree_by(const unsigned char *hash1,
334
334
* shift tree2 down by adding shift_prefix above it
335
335
* to match tree1.
336
336
*/
337
- splice_tree (hash1 , shift_prefix , hash2 , shifted );
337
+ splice_tree (hash1 -> hash , shift_prefix , hash2 -> hash , shifted -> hash );
338
338
else
339
339
/*
340
340
* shift tree2 up by removing shift_prefix from it
341
341
* to match tree1.
342
342
*/
343
- hashcpy (shifted , sub2 );
343
+ oidcpy (shifted , & sub2 );
344
344
}
0 commit comments