@@ -48,17 +48,17 @@ static int score_matches(unsigned mode1, unsigned mode2, const char *path)
48
48
}
49
49
50
50
static void * fill_tree_desc_strict (struct tree_desc * desc ,
51
- const unsigned char * hash )
51
+ const struct object_id * hash )
52
52
{
53
53
void * buffer ;
54
54
enum object_type type ;
55
55
unsigned long size ;
56
56
57
- buffer = read_sha1_file (hash , & type , & size );
57
+ buffer = read_sha1_file (hash -> hash , & type , & size );
58
58
if (!buffer )
59
- die ("unable to read tree (%s)" , sha1_to_hex (hash ));
59
+ die ("unable to read tree (%s)" , oid_to_hex (hash ));
60
60
if (type != OBJ_TREE )
61
- die ("%s is not a tree" , sha1_to_hex (hash ));
61
+ die ("%s is not a tree" , oid_to_hex (hash ));
62
62
init_tree_desc (desc , buffer , size );
63
63
return buffer ;
64
64
}
@@ -73,7 +73,7 @@ static int base_name_entries_compare(const struct name_entry *a,
73
73
/*
74
74
* Inspect two trees, and give a score that tells how similar they are.
75
75
*/
76
- static int score_trees (const unsigned char * hash1 , const unsigned char * hash2 )
76
+ static int score_trees (const struct object_id * hash1 , const struct object_id * hash2 )
77
77
{
78
78
struct tree_desc one ;
79
79
struct tree_desc two ;
@@ -119,8 +119,8 @@ static int score_trees(const unsigned char *hash1, const unsigned char *hash2)
119
119
/*
120
120
* Match one itself and its subtrees with two and pick the best match.
121
121
*/
122
- static void match_trees (const unsigned char * hash1 ,
123
- const unsigned char * hash2 ,
122
+ static void match_trees (const struct object_id * hash1 ,
123
+ const struct object_id * hash2 ,
124
124
int * best_score ,
125
125
char * * best_match ,
126
126
const char * base ,
@@ -138,15 +138,15 @@ static void match_trees(const unsigned char *hash1,
138
138
elem = tree_entry_extract (& one , & path , & mode );
139
139
if (!S_ISDIR (mode ))
140
140
goto next ;
141
- score = score_trees (elem -> hash , hash2 );
141
+ score = score_trees (elem , hash2 );
142
142
if (* best_score < score ) {
143
143
free (* best_match );
144
144
* best_match = xstrfmt ("%s%s" , base , path );
145
145
* best_score = score ;
146
146
}
147
147
if (recurse_limit ) {
148
148
char * newbase = xstrfmt ("%s%s/" , base , path );
149
- match_trees (elem -> hash , hash2 , best_score , best_match ,
149
+ match_trees (elem , hash2 , best_score , best_match ,
150
150
newbase , recurse_limit - 1 );
151
151
free (newbase );
152
152
}
@@ -245,21 +245,21 @@ void shift_tree(const struct object_id *hash1,
245
245
if (!depth_limit )
246
246
depth_limit = 2 ;
247
247
248
- add_score = del_score = score_trees (hash1 -> hash , hash2 -> hash );
248
+ add_score = del_score = score_trees (hash1 , hash2 );
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 -> hash , hash2 -> hash , & add_score , & add_prefix , "" , depth_limit );
256
+ match_trees (hash1 , hash2 , & 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 -> hash , hash1 -> hash , & del_score , & del_prefix , "" , depth_limit );
262
+ match_trees (hash2 , hash1 , & del_score , & del_prefix , "" , depth_limit );
263
263
264
264
/* Assume we do not have to do any shifting */
265
265
oidcpy (shifted , hash2 );
@@ -309,16 +309,16 @@ void shift_tree_by(const struct object_id *hash1,
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 -> hash , hash2 -> hash );
312
+ int best_score = score_trees (hash1 , hash2 );
313
313
int score ;
314
314
315
315
candidate = 0 ;
316
- score = score_trees (sub1 . hash , hash2 -> hash );
316
+ score = score_trees (& sub1 , hash2 );
317
317
if (score > best_score ) {
318
318
candidate = 1 ;
319
319
best_score = score ;
320
320
}
321
- score = score_trees (sub2 . hash , hash1 -> hash );
321
+ score = score_trees (& sub2 , hash1 );
322
322
if (score > best_score )
323
323
candidate = 2 ;
324
324
}
0 commit comments