@@ -1361,6 +1361,9 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
1361
1361
if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version )
1362
1362
return error ("bad index version %d" , hdr_version );
1363
1363
1364
+ /* Initialize the sha before bailing out early so that split-index still works */
1365
+ git_SHA1_Init (& c );
1366
+
1364
1367
/*
1365
1368
Since gitmodules_config runs this code
1366
1369
and is called before git_config(git_default_config, ...)
@@ -1369,7 +1372,6 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
1369
1372
if (gvfs_config_load_and_is_set (GVFS_SKIP_SHA_ON_INDEX ))
1370
1373
return 0 ;
1371
1374
1372
- git_SHA1_Init (& c );
1373
1375
git_SHA1_Update (& c , hdr , size - 20 );
1374
1376
git_SHA1_Final (sha1 , & c );
1375
1377
if (hashcmp (sha1 , (unsigned char * )hdr + size - 20 ))
@@ -1656,11 +1658,13 @@ int read_index_from(struct index_state *istate, const char *path)
1656
1658
if (istate -> initialized )
1657
1659
return istate -> cache_nr ;
1658
1660
1661
+ uint64_t start = getnanotime ();
1659
1662
ret = do_read_index (istate , path , 0 );
1660
1663
1661
1664
split_index = istate -> split_index ;
1662
1665
if (!split_index || is_null_sha1 (split_index -> base_sha1 )) {
1663
1666
post_read_index_from (istate );
1667
+ trace_performance_since (start , "read_index_from" );
1664
1668
return ret ;
1665
1669
}
1666
1670
@@ -1679,6 +1683,7 @@ int read_index_from(struct index_state *istate, const char *path)
1679
1683
sha1_to_hex (split_index -> base -> sha1 ));
1680
1684
merge_base_index (istate );
1681
1685
post_read_index_from (istate );
1686
+ trace_performance_since (start , "read_index_from" );
1682
1687
return ret ;
1683
1688
}
1684
1689
@@ -1795,8 +1800,6 @@ static int ce_flush(git_SHA_CTX *context, int fd, unsigned char *sha1)
1795
1800
/* Append the SHA1 signature at the end */
1796
1801
if (!gvfs_config_is_set (GVFS_SKIP_SHA_ON_INDEX ))
1797
1802
git_SHA1_Final (write_buffer + left , context );
1798
- else
1799
- hashclr (write_buffer + left );
1800
1803
hashcpy (sha1 , write_buffer + left );
1801
1804
left += 20 ;
1802
1805
return (write_in_full (fd , write_buffer , left ) != left ) ? -1 : 0 ;
@@ -2193,13 +2196,17 @@ static int write_shared_index(struct index_state *istate,
2193
2196
int write_locked_index (struct index_state * istate , struct lock_file * lock ,
2194
2197
unsigned flags )
2195
2198
{
2199
+ uint64_t start = getnanotime ();
2196
2200
struct split_index * si = istate -> split_index ;
2201
+ int ret ;
2197
2202
2198
2203
if (!si || alternate_index_output ||
2199
2204
(istate -> cache_changed & ~EXTMASK )) {
2200
2205
if (si )
2201
2206
hashclr (si -> base_sha1 );
2202
- return do_write_locked_index (istate , lock , flags );
2207
+ ret = do_write_locked_index (istate , lock , flags );
2208
+ trace_performance_since (start , "write_locked_index" );
2209
+ return ret ;
2203
2210
}
2204
2211
2205
2212
if (getenv ("GIT_TEST_SPLIT_INDEX" )) {
@@ -2208,12 +2215,16 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
2208
2215
istate -> cache_changed |= SPLIT_INDEX_ORDERED ;
2209
2216
}
2210
2217
if (istate -> cache_changed & SPLIT_INDEX_ORDERED ) {
2211
- int ret = write_shared_index (istate , lock , flags );
2212
- if (ret )
2218
+ ret = write_shared_index (istate , lock , flags );
2219
+ if (ret ) {
2220
+ trace_performance_since (start , "write_locked_index" );
2213
2221
return ret ;
2222
+ }
2214
2223
}
2215
2224
2216
- return write_split_index (istate , lock , flags );
2225
+ ret = write_split_index (istate , lock , flags );
2226
+ trace_performance_since (start , "write_locked_index" );
2227
+ return ret ;
2217
2228
}
2218
2229
2219
2230
/*
0 commit comments