@@ -158,22 +158,20 @@ static void match_trees(const struct object_id *hash1,
158
158
}
159
159
160
160
/*
161
- * A tree "hash1 " has a subdirectory at "prefix". Come up with a
162
- * tree object by replacing it with another tree "hash2 ".
161
+ * A tree "oid1 " has a subdirectory at "prefix". Come up with a tree object by
162
+ * replacing it with another tree "oid2 ".
163
163
*/
164
- static int splice_tree (const unsigned char * hash1 ,
165
- const char * prefix ,
166
- const unsigned char * hash2 ,
167
- unsigned char * result )
164
+ static int splice_tree (const struct object_id * oid1 , const char * prefix ,
165
+ const struct object_id * oid2 , struct object_id * result )
168
166
{
169
167
char * subpath ;
170
168
int toplen ;
171
169
char * buf ;
172
170
unsigned long sz ;
173
171
struct tree_desc desc ;
174
- unsigned char * rewrite_here ;
175
- const unsigned char * rewrite_with ;
176
- unsigned char subtree [ 20 ] ;
172
+ struct object_id * rewrite_here ;
173
+ const struct object_id * rewrite_with ;
174
+ struct object_id subtree ;
177
175
enum object_type type ;
178
176
int status ;
179
177
@@ -182,9 +180,9 @@ static int splice_tree(const unsigned char *hash1,
182
180
if (* subpath )
183
181
subpath ++ ;
184
182
185
- buf = read_sha1_file (hash1 , & type , & sz );
183
+ buf = read_sha1_file (oid1 -> hash , & type , & sz );
186
184
if (!buf )
187
- die ("cannot read tree %s" , sha1_to_hex ( hash1 ));
185
+ die ("cannot read tree %s" , oid_to_hex ( oid1 ));
188
186
init_tree_desc (& desc , buf , sz );
189
187
190
188
rewrite_here = NULL ;
@@ -197,26 +195,26 @@ static int splice_tree(const unsigned char *hash1,
197
195
if (strlen (name ) == toplen &&
198
196
!memcmp (name , prefix , toplen )) {
199
197
if (!S_ISDIR (mode ))
200
- die ("entry %s in tree %s is not a tree" ,
201
- name , sha1_to_hex ( hash1 ));
202
- rewrite_here = (unsigned char * ) oid -> hash ;
198
+ die ("entry %s in tree %s is not a tree" , name ,
199
+ oid_to_hex ( oid1 ));
200
+ rewrite_here = (struct object_id * )oid ;
203
201
break ;
204
202
}
205
203
update_tree_entry (& desc );
206
204
}
207
205
if (!rewrite_here )
208
- die ("entry %.*s not found in tree %s" ,
209
- toplen , prefix , sha1_to_hex ( hash1 ));
206
+ die ("entry %.*s not found in tree %s" , toplen , prefix ,
207
+ oid_to_hex ( oid1 ));
210
208
if (* subpath ) {
211
- status = splice_tree (rewrite_here , subpath , hash2 , subtree );
209
+ status = splice_tree (rewrite_here , subpath , oid2 , & subtree );
212
210
if (status )
213
211
return status ;
214
- rewrite_with = subtree ;
212
+ rewrite_with = & subtree ;
213
+ } else {
214
+ rewrite_with = oid2 ;
215
215
}
216
- else
217
- rewrite_with = hash2 ;
218
- hashcpy (rewrite_here , rewrite_with );
219
- status = write_sha1_file (buf , sz , tree_type , result );
216
+ oidcpy (rewrite_here , rewrite_with );
217
+ status = write_sha1_file (buf , sz , tree_type , result -> hash );
220
218
free (buf );
221
219
return status ;
222
220
}
@@ -280,7 +278,7 @@ void shift_tree(const struct object_id *hash1,
280
278
if (!* add_prefix )
281
279
return ;
282
280
283
- splice_tree (hash1 -> hash , add_prefix , hash2 -> hash , shifted -> hash );
281
+ splice_tree (hash1 , add_prefix , hash2 , shifted );
284
282
}
285
283
286
284
/*
@@ -334,7 +332,7 @@ void shift_tree_by(const struct object_id *hash1,
334
332
* shift tree2 down by adding shift_prefix above it
335
333
* to match tree1.
336
334
*/
337
- splice_tree (hash1 -> hash , shift_prefix , hash2 -> hash , shifted -> hash );
335
+ splice_tree (hash1 , shift_prefix , hash2 , shifted );
338
336
else
339
337
/*
340
338
* shift tree2 up by removing shift_prefix from it
0 commit comments