@@ -2172,7 +2172,6 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
21722172
21732173 src_offset = sizeof (* hdr );
21742174
2175- if (HAVE_THREADS ) {
21762175 nr_threads = git_config_get_index_threads ();
21772176
21782177 /* TODO: does creating more threads than cores help? */
@@ -2183,6 +2182,9 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
21832182 nr_threads = cpus ;
21842183 }
21852184
2185+ if (!HAVE_THREADS )
2186+ nr_threads = 1 ;
2187+
21862188 if (nr_threads > 1 ) {
21872189 extension_offset = read_eoie_extension (mmap , mmap_size );
21882190 if (extension_offset ) {
@@ -2210,20 +2212,16 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22102212 } else {
22112213 src_offset += load_all_cache_entries (istate , mmap , mmap_size , src_offset );
22122214 }
2213- } else {
2214- src_offset += load_all_cache_entries (istate , mmap , mmap_size , src_offset );
2215- }
22162215
22172216 istate -> timestamp .sec = st .st_mtime ;
22182217 istate -> timestamp .nsec = ST_MTIME_NSEC (st );
22192218
22202219 /* if we created a thread, join it otherwise load the extensions on the primary thread */
2221- if (HAVE_THREADS && extension_offset ) {
2220+ if (extension_offset ) {
22222221 int ret = pthread_join (p .pthread , NULL );
22232222 if (ret )
22242223 die (_ ("unable to join load_index_extensions thread: %s" ), strerror (ret ));
2225- }
2226- if (!extension_offset ) {
2224+ } else {
22272225 p .src_offset = src_offset ;
22282226 load_index_extensions (& p );
22292227 }
@@ -2745,8 +2743,10 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
27452743 if (ce_write (& c , newfd , & hdr , sizeof (hdr )) < 0 )
27462744 return -1 ;
27472745
2748- if (HAVE_THREADS ) {
2746+ if (HAVE_THREADS )
27492747 nr_threads = git_config_get_index_threads ();
2748+ else
2749+ nr_threads = 1 ;
27502750
27512751 if (nr_threads != 1 ) {
27522752 int ieot_blocks , cpus ;
@@ -2777,7 +2777,6 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
27772777 ieot_entries = DIV_ROUND_UP (entries , ieot_blocks );
27782778 }
27792779 }
2780- }
27812780
27822781 offset = lseek (newfd , 0 , SEEK_CUR );
27832782 if (offset < 0 ) {
@@ -2861,7 +2860,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
28612860 * strip_extensions parameter as we need it when loading the shared
28622861 * index.
28632862 */
2864- if (HAVE_THREADS && ieot ) {
2863+ if (ieot ) {
28652864 struct strbuf sb = STRBUF_INIT ;
28662865
28672866 write_ieot_extension (& sb , ieot );
0 commit comments