@@ -225,7 +225,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
225
225
int i ;
226
226
if (!it )
227
227
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 ))
229
229
return 0 ;
230
230
for (i = 0 ; i < it -> subtree_nr ; i ++ ) {
231
231
if (!cache_tree_fully_valid (it -> down [i ]-> cache_tree ))
@@ -253,7 +253,7 @@ static int update_one(struct cache_tree *it,
253
253
254
254
* skip_count = 0 ;
255
255
256
- if (0 <= it -> entry_count && has_sha1_file (it -> sha1 ))
256
+ if (0 <= it -> entry_count && has_sha1_file (it -> oid . hash ))
257
257
return it -> entry_count ;
258
258
259
259
/*
@@ -340,7 +340,7 @@ static int update_one(struct cache_tree *it,
340
340
die ("cache-tree.c: '%.*s' in '%s' not found" ,
341
341
entlen , path + baselen , path );
342
342
i += sub -> count ;
343
- sha1 = sub -> cache_tree -> sha1 ;
343
+ sha1 = sub -> cache_tree -> oid . hash ;
344
344
mode = S_IFDIR ;
345
345
contains_ita = sub -> cache_tree -> entry_count < 0 ;
346
346
if (contains_ita ) {
@@ -402,12 +402,13 @@ static int update_one(struct cache_tree *it,
402
402
unsigned char sha1 [20 ];
403
403
hash_sha1_file (buffer .buf , buffer .len , tree_type , sha1 );
404
404
if (has_sha1_file (sha1 ))
405
- hashcpy (it -> sha1 , sha1 );
405
+ hashcpy (it -> oid . hash , sha1 );
406
406
else
407
407
to_invalidate = 1 ;
408
408
} 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 )) {
411
412
strbuf_release (& buffer );
412
413
return -1 ;
413
414
}
@@ -417,7 +418,7 @@ static int update_one(struct cache_tree *it,
417
418
#if DEBUG
418
419
fprintf (stderr , "cache-tree update-one (%d ent, %d subtree) %s\n" ,
419
420
it -> entry_count , it -> subtree_nr ,
420
- sha1_to_hex ( it -> sha1 ));
421
+ oid_to_hex ( & it -> oid ));
421
422
#endif
422
423
return i ;
423
424
}
@@ -457,14 +458,14 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
457
458
if (0 <= it -> entry_count )
458
459
fprintf (stderr , "cache-tree <%.*s> (%d ent, %d subtree) %s\n" ,
459
460
pathlen , path , it -> entry_count , it -> subtree_nr ,
460
- sha1_to_hex ( it -> sha1 ));
461
+ oid_to_hex ( & it -> oid ));
461
462
else
462
463
fprintf (stderr , "cache-tree <%.*s> (%d subtree) invalid\n" ,
463
464
pathlen , path , it -> subtree_nr );
464
465
#endif
465
466
466
467
if (0 <= it -> entry_count ) {
467
- strbuf_add (buffer , it -> sha1 , 20 );
468
+ strbuf_add (buffer , it -> oid . hash , 20 );
468
469
}
469
470
for (i = 0 ; i < it -> subtree_nr ; i ++ ) {
470
471
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)
521
522
if (0 <= it -> entry_count ) {
522
523
if (size < 20 )
523
524
goto free_return ;
524
- hashcpy (it -> sha1 , (const unsigned char * )buf );
525
+ hashcpy (it -> oid . hash , (const unsigned char * )buf );
525
526
buf += 20 ;
526
527
size -= 20 ;
527
528
}
@@ -530,7 +531,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
530
531
if (0 <= it -> entry_count )
531
532
fprintf (stderr , "cache-tree <%s> (%d ent, %d subtree) %s\n" ,
532
533
* buffer , it -> entry_count , subtree_nr ,
533
- sha1_to_hex ( it -> sha1 ));
534
+ oid_to_hex ( & it -> oid ));
534
535
else
535
536
fprintf (stderr , "cache-tree <%s> (%d subtrees) invalid\n" ,
536
537
* buffer , subtree_nr );
@@ -641,10 +642,10 @@ int write_index_as_tree(unsigned char *sha1, struct index_state *index_state, co
641
642
subtree = cache_tree_find (index_state -> cache_tree , prefix );
642
643
if (!subtree )
643
644
return WRITE_TREE_PREFIX_ERROR ;
644
- hashcpy (sha1 , subtree -> sha1 );
645
+ hashcpy (sha1 , subtree -> oid . hash );
645
646
}
646
647
else
647
- hashcpy (sha1 , index_state -> cache_tree -> sha1 );
648
+ hashcpy (sha1 , index_state -> cache_tree -> oid . hash );
648
649
649
650
if (0 <= newfd )
650
651
rollback_lock_file (lock_file );
@@ -663,7 +664,7 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
663
664
struct name_entry entry ;
664
665
int cnt ;
665
666
666
- hashcpy ( it -> sha1 , tree -> object .oid . hash );
667
+ oidcpy ( & it -> oid , & tree -> object .oid );
667
668
init_tree_desc (& desc , tree -> buffer , tree -> size );
668
669
cnt = 0 ;
669
670
while (tree_entry (& desc , & entry )) {
@@ -718,7 +719,7 @@ int cache_tree_matches_traversal(struct cache_tree *root,
718
719
719
720
it = find_cache_tree_from_traversal (root , info );
720
721
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 ))
722
723
return it -> entry_count ;
723
724
return 0 ;
724
725
}
0 commit comments