55#include "pathspec.h"
66
77#ifdef NO_PTHREADS
8- static void preload_index (struct index_state * index , const char * * pathspec )
8+ static void preload_index (struct index_state * index ,
9+ const struct pathspec * pathspec )
910{
1011 ; /* nothing */
1112}
@@ -25,7 +26,7 @@ static void preload_index(struct index_state *index, const char **pathspec)
2526struct thread_data {
2627 pthread_t pthread ;
2728 struct index_state * index ;
28- const char * * pathspec ;
29+ struct pathspec pathspec ;
2930 int offset , nr ;
3031};
3132
@@ -36,9 +37,7 @@ static void *preload_thread(void *_data)
3637 struct index_state * index = p -> index ;
3738 struct cache_entry * * cep = index -> cache + p -> offset ;
3839 struct cache_def cache ;
39- struct pathspec pathspec ;
4040
41- init_pathspec (& pathspec , p -> pathspec );
4241 memset (& cache , 0 , sizeof (cache ));
4342 nr = p -> nr ;
4443 if (nr + p -> offset > index -> cache_nr )
@@ -54,7 +53,7 @@ static void *preload_thread(void *_data)
5453 continue ;
5554 if (ce_uptodate (ce ))
5655 continue ;
57- if (!ce_path_match (ce , & pathspec ))
56+ if (!ce_path_match (ce , & p -> pathspec ))
5857 continue ;
5958 if (threaded_has_symlink_leading_path (& cache , ce -> name , ce_namelen (ce )))
6059 continue ;
@@ -64,11 +63,11 @@ static void *preload_thread(void *_data)
6463 continue ;
6564 ce_mark_uptodate (ce );
6665 } while (-- nr > 0 );
67- free_pathspec (& pathspec );
6866 return NULL ;
6967}
7068
71- static void preload_index (struct index_state * index , const char * * pathspec )
69+ static void preload_index (struct index_state * index ,
70+ const struct pathspec * pathspec )
7271{
7372 int threads , i , work , offset ;
7473 struct thread_data data [MAX_PARALLEL ];
@@ -83,10 +82,12 @@ static void preload_index(struct index_state *index, const char **pathspec)
8382 threads = MAX_PARALLEL ;
8483 offset = 0 ;
8584 work = DIV_ROUND_UP (index -> cache_nr , threads );
85+ memset (& data , 0 , sizeof (data ));
8686 for (i = 0 ; i < threads ; i ++ ) {
8787 struct thread_data * p = data + i ;
8888 p -> index = index ;
89- p -> pathspec = pathspec ;
89+ if (pathspec )
90+ copy_pathspec (& p -> pathspec , pathspec );
9091 p -> offset = offset ;
9192 p -> nr = work ;
9293 offset += work ;
@@ -101,7 +102,8 @@ static void preload_index(struct index_state *index, const char **pathspec)
101102}
102103#endif
103104
104- int read_index_preload (struct index_state * index , const char * * pathspec )
105+ int read_index_preload (struct index_state * index ,
106+ const struct pathspec * pathspec )
105107{
106108 int retval = read_index (index );
107109
0 commit comments