@@ -225,7 +225,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
225225 int i ;
226226 if (!it )
227227 return 0 ;
228- if (it -> entry_count < 0 || !has_sha1_file (it -> sha1 ))
228+ if (it -> entry_count < 0 || !has_sha1_file (it -> oid . hash ))
229229 return 0 ;
230230 for (i = 0 ; i < it -> subtree_nr ; i ++ ) {
231231 if (!cache_tree_fully_valid (it -> down [i ]-> cache_tree ))
@@ -253,7 +253,7 @@ static int update_one(struct cache_tree *it,
253253
254254 * skip_count = 0 ;
255255
256- if (0 <= it -> entry_count && has_sha1_file (it -> sha1 ))
256+ if (0 <= it -> entry_count && has_sha1_file (it -> oid . hash ))
257257 return it -> entry_count ;
258258
259259 /*
@@ -340,7 +340,7 @@ static int update_one(struct cache_tree *it,
340340 die ("cache-tree.c: '%.*s' in '%s' not found" ,
341341 entlen , path + baselen , path );
342342 i += sub -> count ;
343- sha1 = sub -> cache_tree -> sha1 ;
343+ sha1 = sub -> cache_tree -> oid . hash ;
344344 mode = S_IFDIR ;
345345 contains_ita = sub -> cache_tree -> entry_count < 0 ;
346346 if (contains_ita ) {
@@ -402,12 +402,13 @@ static int update_one(struct cache_tree *it,
402402 unsigned char sha1 [20 ];
403403 hash_sha1_file (buffer .buf , buffer .len , tree_type , sha1 );
404404 if (has_sha1_file (sha1 ))
405- hashcpy (it -> sha1 , sha1 );
405+ hashcpy (it -> oid . hash , sha1 );
406406 else
407407 to_invalidate = 1 ;
408408 } else if (dryrun )
409- hash_sha1_file (buffer .buf , buffer .len , tree_type , it -> sha1 );
410- else if (write_sha1_file (buffer .buf , buffer .len , tree_type , it -> sha1 )) {
409+ hash_sha1_file (buffer .buf , buffer .len , tree_type ,
410+ it -> oid .hash );
411+ else if (write_sha1_file (buffer .buf , buffer .len , tree_type , it -> oid .hash )) {
411412 strbuf_release (& buffer );
412413 return -1 ;
413414 }
@@ -417,7 +418,7 @@ static int update_one(struct cache_tree *it,
417418#if DEBUG
418419 fprintf (stderr , "cache-tree update-one (%d ent, %d subtree) %s\n" ,
419420 it -> entry_count , it -> subtree_nr ,
420- sha1_to_hex ( it -> sha1 ));
421+ oid_to_hex ( & it -> oid ));
421422#endif
422423 return i ;
423424}
@@ -457,14 +458,14 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
457458 if (0 <= it -> entry_count )
458459 fprintf (stderr , "cache-tree <%.*s> (%d ent, %d subtree) %s\n" ,
459460 pathlen , path , it -> entry_count , it -> subtree_nr ,
460- sha1_to_hex ( it -> sha1 ));
461+ oid_to_hex ( & it -> oid ));
461462 else
462463 fprintf (stderr , "cache-tree <%.*s> (%d subtree) invalid\n" ,
463464 pathlen , path , it -> subtree_nr );
464465#endif
465466
466467 if (0 <= it -> entry_count ) {
467- strbuf_add (buffer , it -> sha1 , 20 );
468+ strbuf_add (buffer , it -> oid . hash , 20 );
468469 }
469470 for (i = 0 ; i < it -> subtree_nr ; i ++ ) {
470471 struct cache_tree_sub * down = it -> down [i ];
@@ -521,7 +522,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
521522 if (0 <= it -> entry_count ) {
522523 if (size < 20 )
523524 goto free_return ;
524- hashcpy (it -> sha1 , (const unsigned char * )buf );
525+ hashcpy (it -> oid . hash , (const unsigned char * )buf );
525526 buf += 20 ;
526527 size -= 20 ;
527528 }
@@ -530,7 +531,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
530531 if (0 <= it -> entry_count )
531532 fprintf (stderr , "cache-tree <%s> (%d ent, %d subtree) %s\n" ,
532533 * buffer , it -> entry_count , subtree_nr ,
533- sha1_to_hex ( it -> sha1 ));
534+ oid_to_hex ( & it -> oid ));
534535 else
535536 fprintf (stderr , "cache-tree <%s> (%d subtrees) invalid\n" ,
536537 * buffer , subtree_nr );
@@ -641,10 +642,10 @@ int write_index_as_tree(unsigned char *sha1, struct index_state *index_state, co
641642 subtree = cache_tree_find (index_state -> cache_tree , prefix );
642643 if (!subtree )
643644 return WRITE_TREE_PREFIX_ERROR ;
644- hashcpy (sha1 , subtree -> sha1 );
645+ hashcpy (sha1 , subtree -> oid . hash );
645646 }
646647 else
647- hashcpy (sha1 , index_state -> cache_tree -> sha1 );
648+ hashcpy (sha1 , index_state -> cache_tree -> oid . hash );
648649
649650 if (0 <= newfd )
650651 rollback_lock_file (lock_file );
@@ -663,7 +664,7 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
663664 struct name_entry entry ;
664665 int cnt ;
665666
666- hashcpy ( it -> sha1 , tree -> object .oid . hash );
667+ oidcpy ( & it -> oid , & tree -> object .oid );
667668 init_tree_desc (& desc , tree -> buffer , tree -> size );
668669 cnt = 0 ;
669670 while (tree_entry (& desc , & entry )) {
@@ -718,7 +719,7 @@ int cache_tree_matches_traversal(struct cache_tree *root,
718719
719720 it = find_cache_tree_from_traversal (root , info );
720721 it = cache_tree_find (it , ent -> path );
721- if (it && it -> entry_count > 0 && !hashcmp (ent -> oid -> hash , it -> sha1 ))
722+ if (it && it -> entry_count > 0 && !oidcmp (ent -> oid , & it -> oid ))
722723 return it -> entry_count ;
723724 return 0 ;
724725}
0 commit comments