@@ -46,7 +46,8 @@ struct cached_dir {
4646};
4747
4848static enum path_treatment read_directory_recursive (struct dir_struct * dir ,
49- const char * path , int len , struct untracked_cache_dir * untracked ,
49+ struct index_state * istate , const char * path , int len ,
50+ struct untracked_cache_dir * untracked ,
5051 int check_only , const struct pathspec * pathspec );
5152static int get_dtype (struct dirent * de , struct index_state * istate ,
5253 const char * path , int len );
@@ -1362,12 +1363,13 @@ static enum exist_status directory_exists_in_index(struct index_state *istate,
13621363 * (c) otherwise, we recurse into it.
13631364 */
13641365static enum path_treatment treat_directory (struct dir_struct * dir ,
1366+ struct index_state * istate ,
13651367 struct untracked_cache_dir * untracked ,
13661368 const char * dirname , int len , int baselen , int exclude ,
13671369 const struct pathspec * pathspec )
13681370{
13691371 /* The "len-1" is to strip the final '/' */
1370- switch (directory_exists_in_index (& the_index , dirname , len - 1 )) {
1372+ switch (directory_exists_in_index (istate , dirname , len - 1 )) {
13711373 case index_directory :
13721374 return path_recurse ;
13731375
@@ -1392,7 +1394,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
13921394
13931395 untracked = lookup_untracked (dir -> untracked , untracked ,
13941396 dirname + baselen , len - baselen );
1395- return read_directory_recursive (dir , dirname , len ,
1397+ return read_directory_recursive (dir , istate , dirname , len ,
13961398 untracked , 1 , pathspec );
13971399}
13981400
@@ -1536,16 +1538,17 @@ static int get_dtype(struct dirent *de, struct index_state *istate,
15361538
15371539static enum path_treatment treat_one_path (struct dir_struct * dir ,
15381540 struct untracked_cache_dir * untracked ,
1541+ struct index_state * istate ,
15391542 struct strbuf * path ,
15401543 int baselen ,
15411544 const struct pathspec * pathspec ,
15421545 int dtype , struct dirent * de )
15431546{
15441547 int exclude ;
1545- int has_path_in_index = !!index_file_exists (& the_index , path -> buf , path -> len , ignore_case );
1548+ int has_path_in_index = !!index_file_exists (istate , path -> buf , path -> len , ignore_case );
15461549
15471550 if (dtype == DT_UNKNOWN )
1548- dtype = get_dtype (de , & the_index , path -> buf , path -> len );
1551+ dtype = get_dtype (de , istate , path -> buf , path -> len );
15491552
15501553 /* Always exclude indexed files */
15511554 if (dtype != DT_DIR && has_path_in_index )
@@ -1572,10 +1575,10 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
15721575 if ((dir -> flags & DIR_COLLECT_KILLED_ONLY ) &&
15731576 (dtype == DT_DIR ) &&
15741577 !has_path_in_index &&
1575- (directory_exists_in_index (& the_index , path -> buf , path -> len ) == index_nonexistent ))
1578+ (directory_exists_in_index (istate , path -> buf , path -> len ) == index_nonexistent ))
15761579 return path_none ;
15771580
1578- exclude = is_excluded (dir , & the_index , path -> buf , & dtype );
1581+ exclude = is_excluded (dir , istate , path -> buf , & dtype );
15791582
15801583 /*
15811584 * Excluded? If we don't explicitly want to show
@@ -1589,7 +1592,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
15891592 return path_none ;
15901593 case DT_DIR :
15911594 strbuf_addch (path , '/' );
1592- return treat_directory (dir , untracked , path -> buf , path -> len ,
1595+ return treat_directory (dir , istate , untracked , path -> buf , path -> len ,
15931596 baselen , exclude , pathspec );
15941597 case DT_REG :
15951598 case DT_LNK :
@@ -1600,6 +1603,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
16001603static enum path_treatment treat_path_fast (struct dir_struct * dir ,
16011604 struct untracked_cache_dir * untracked ,
16021605 struct cached_dir * cdir ,
1606+ struct index_state * istate ,
16031607 struct strbuf * path ,
16041608 int baselen ,
16051609 const struct pathspec * pathspec )
@@ -1618,7 +1622,7 @@ static enum path_treatment treat_path_fast(struct dir_struct *dir,
16181622 * to its bottom. Verify again the same set of directories
16191623 * with check_only set.
16201624 */
1621- return read_directory_recursive (dir , path -> buf , path -> len ,
1625+ return read_directory_recursive (dir , istate , path -> buf , path -> len ,
16221626 cdir -> ucd , 1 , pathspec );
16231627 /*
16241628 * We get path_recurse in the first run when
@@ -1632,6 +1636,7 @@ static enum path_treatment treat_path_fast(struct dir_struct *dir,
16321636static enum path_treatment treat_path (struct dir_struct * dir ,
16331637 struct untracked_cache_dir * untracked ,
16341638 struct cached_dir * cdir ,
1639+ struct index_state * istate ,
16351640 struct strbuf * path ,
16361641 int baselen ,
16371642 const struct pathspec * pathspec )
@@ -1640,7 +1645,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,
16401645 struct dirent * de = cdir -> de ;
16411646
16421647 if (!de )
1643- return treat_path_fast (dir , untracked , cdir , path ,
1648+ return treat_path_fast (dir , untracked , cdir , istate , path ,
16441649 baselen , pathspec );
16451650 if (is_dot_or_dotdot (de -> d_name ) || !strcmp (de -> d_name , ".git" ))
16461651 return path_none ;
@@ -1650,7 +1655,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,
16501655 return path_none ;
16511656
16521657 dtype = DTYPE (de );
1653- return treat_one_path (dir , untracked , path , baselen , pathspec , dtype , de );
1658+ return treat_one_path (dir , untracked , istate , path , baselen , pathspec , dtype , de );
16541659}
16551660
16561661static void add_untracked (struct untracked_cache_dir * dir , const char * name )
@@ -1781,25 +1786,25 @@ static void close_cached_dir(struct cached_dir *cdir)
17811786 * Returns the most significant path_treatment value encountered in the scan.
17821787 */
17831788static enum path_treatment read_directory_recursive (struct dir_struct * dir ,
1784- const char * base , int baselen ,
1785- struct untracked_cache_dir * untracked , int check_only ,
1786- const struct pathspec * pathspec )
1789+ struct index_state * istate , const char * base , int baselen ,
1790+ struct untracked_cache_dir * untracked , int check_only ,
1791+ const struct pathspec * pathspec )
17871792{
17881793 struct cached_dir cdir ;
17891794 enum path_treatment state , subdir_state , dir_state = path_none ;
17901795 struct strbuf path = STRBUF_INIT ;
17911796
17921797 strbuf_add (& path , base , baselen );
17931798
1794- if (open_cached_dir (& cdir , dir , untracked , & the_index , & path , check_only ))
1799+ if (open_cached_dir (& cdir , dir , untracked , istate , & path , check_only ))
17951800 goto out ;
17961801
17971802 if (untracked )
17981803 untracked -> check_only = !!check_only ;
17991804
18001805 while (!read_cached_dir (& cdir )) {
18011806 /* check how the file or directory should be treated */
1802- state = treat_path (dir , untracked , & cdir , & path ,
1807+ state = treat_path (dir , untracked , & cdir , istate , & path ,
18031808 baselen , pathspec );
18041809
18051810 if (state > dir_state )
@@ -1812,7 +1817,7 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
18121817 path .buf + baselen ,
18131818 path .len - baselen );
18141819 subdir_state =
1815- read_directory_recursive (dir , path .buf ,
1820+ read_directory_recursive (dir , istate , path .buf ,
18161821 path .len , ud ,
18171822 check_only , pathspec );
18181823 if (subdir_state > dir_state )
@@ -1834,18 +1839,18 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
18341839 switch (state ) {
18351840 case path_excluded :
18361841 if (dir -> flags & DIR_SHOW_IGNORED )
1837- dir_add_name (dir , & the_index , path .buf , path .len );
1842+ dir_add_name (dir , istate , path .buf , path .len );
18381843 else if ((dir -> flags & DIR_SHOW_IGNORED_TOO ) ||
18391844 ((dir -> flags & DIR_COLLECT_IGNORED ) &&
18401845 exclude_matches_pathspec (path .buf , path .len ,
18411846 pathspec )))
1842- dir_add_ignored (dir , & the_index , path .buf , path .len );
1847+ dir_add_ignored (dir , istate , path .buf , path .len );
18431848 break ;
18441849
18451850 case path_untracked :
18461851 if (dir -> flags & DIR_SHOW_IGNORED )
18471852 break ;
1848- dir_add_name (dir , & the_index , path .buf , path .len );
1853+ dir_add_name (dir , istate , path .buf , path .len );
18491854 if (cdir .fdir )
18501855 add_untracked (untracked , path .buf + baselen );
18511856 break ;
@@ -1870,6 +1875,7 @@ static int cmp_name(const void *p1, const void *p2)
18701875}
18711876
18721877static int treat_leading_path (struct dir_struct * dir ,
1878+ struct index_state * istate ,
18731879 const char * path , int len ,
18741880 const struct pathspec * pathspec )
18751881{
@@ -1897,7 +1903,7 @@ static int treat_leading_path(struct dir_struct *dir,
18971903 break ;
18981904 if (simplify_away (sb .buf , sb .len , pathspec ))
18991905 break ;
1900- if (treat_one_path (dir , NULL , & sb , baselen , pathspec ,
1906+ if (treat_one_path (dir , NULL , istate , & sb , baselen , pathspec ,
19011907 DT_DIR , NULL ) == path_none )
19021908 break ; /* do not recurse into it */
19031909 if (len <= baselen ) {
@@ -2080,8 +2086,8 @@ int read_directory(struct dir_struct *dir, const char *path,
20802086 * e.g. prep_exclude()
20812087 */
20822088 dir -> untracked = NULL ;
2083- if (!len || treat_leading_path (dir , path , len , pathspec ))
2084- read_directory_recursive (dir , path , len , untracked , 0 , pathspec );
2089+ if (!len || treat_leading_path (dir , & the_index , path , len , pathspec ))
2090+ read_directory_recursive (dir , & the_index , path , len , untracked , 0 , pathspec );
20852091 QSORT (dir -> entries , dir -> nr , cmp_name );
20862092 QSORT (dir -> ignored , dir -> ignored_nr , cmp_name );
20872093 if (dir -> untracked ) {
0 commit comments