@@ -1605,13 +1605,10 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)
1605
1605
}
1606
1606
}
1607
1607
1608
- static int ce_write_entry (git_SHA_CTX * c , int fd , struct cache_entry * ce )
1608
+ /* Copy miscellaneous fields but not the name */
1609
+ static char * copy_cache_entry_to_ondisk (struct ondisk_cache_entry * ondisk ,
1610
+ struct cache_entry * ce )
1609
1611
{
1610
- int size = ondisk_ce_size (ce );
1611
- struct ondisk_cache_entry * ondisk = xcalloc (1 , size );
1612
- char * name ;
1613
- int result ;
1614
-
1615
1612
ondisk -> ctime .sec = htonl (ce -> ce_ctime .sec );
1616
1613
ondisk -> mtime .sec = htonl (ce -> ce_mtime .sec );
1617
1614
ondisk -> ctime .nsec = htonl (ce -> ce_ctime .nsec );
@@ -1628,10 +1625,21 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce)
1628
1625
struct ondisk_cache_entry_extended * ondisk2 ;
1629
1626
ondisk2 = (struct ondisk_cache_entry_extended * )ondisk ;
1630
1627
ondisk2 -> flags2 = htons ((ce -> ce_flags & CE_EXTENDED_FLAGS ) >> 16 );
1631
- name = ondisk2 -> name ;
1628
+ return ondisk2 -> name ;
1632
1629
}
1633
- else
1634
- name = ondisk -> name ;
1630
+ else {
1631
+ return ondisk -> name ;
1632
+ }
1633
+ }
1634
+
1635
+ static int ce_write_entry (git_SHA_CTX * c , int fd , struct cache_entry * ce )
1636
+ {
1637
+ int size = ondisk_ce_size (ce );
1638
+ struct ondisk_cache_entry * ondisk = xcalloc (1 , size );
1639
+ char * name ;
1640
+ int result ;
1641
+
1642
+ name = copy_cache_entry_to_ondisk (ondisk , ce );
1635
1643
memcpy (name , ce -> name , ce_namelen (ce ));
1636
1644
1637
1645
result = ce_write (c , fd , ondisk , size );
0 commit comments