@@ -843,7 +843,7 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
843843 * Returns the exclude_list element which matched, or NULL for
844844 * undecided.
845845 */
846- static struct exclude * last_exclude_matching (struct dir_struct * dir ,
846+ struct exclude * last_exclude_matching (struct dir_struct * dir ,
847847 const char * pathname ,
848848 int * dtype_p )
849849{
@@ -865,7 +865,7 @@ static struct exclude *last_exclude_matching(struct dir_struct *dir,
865865 * scans all exclude lists to determine whether pathname is excluded.
866866 * Returns 1 if true, otherwise 0.
867867 */
868- static int is_excluded (struct dir_struct * dir , const char * pathname , int * dtype_p )
868+ int is_excluded (struct dir_struct * dir , const char * pathname , int * dtype_p )
869869{
870870 struct exclude * exclude =
871871 last_exclude_matching (dir , pathname , dtype_p );
@@ -874,47 +874,6 @@ static int is_excluded(struct dir_struct *dir, const char *pathname, int *dtype_
874874 return 0 ;
875875}
876876
877- void path_exclude_check_init (struct path_exclude_check * check ,
878- struct dir_struct * dir )
879- {
880- check -> dir = dir ;
881- }
882-
883- void path_exclude_check_clear (struct path_exclude_check * check )
884- {
885- }
886-
887- /*
888- * For each subdirectory in name, starting with the top-most, checks
889- * to see if that subdirectory is excluded, and if so, returns the
890- * corresponding exclude structure. Otherwise, checks whether name
891- * itself (which is presumably a file) is excluded.
892- *
893- * A path to a directory known to be excluded is left in check->path to
894- * optimize for repeated checks for files in the same excluded directory.
895- */
896- struct exclude * last_exclude_matching_path (struct path_exclude_check * check ,
897- const char * name , int namelen ,
898- int * dtype )
899- {
900- return last_exclude_matching (check -> dir , name , dtype );
901- }
902-
903- /*
904- * Is this name excluded? This is for a caller like show_files() that
905- * do not honor directory hierarchy and iterate through paths that are
906- * possibly in an ignored directory.
907- */
908- int is_path_excluded (struct path_exclude_check * check ,
909- const char * name , int namelen , int * dtype )
910- {
911- struct exclude * exclude =
912- last_exclude_matching_path (check , name , namelen , dtype );
913- if (exclude )
914- return exclude -> flags & EXC_FLAG_NEGATIVE ? 0 : 1 ;
915- return 0 ;
916- }
917-
918877static struct dir_entry * dir_entry_new (const char * pathname , int len )
919878{
920879 struct dir_entry * ent ;
@@ -1086,15 +1045,6 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
10861045
10871046 /* This is the "show_other_directories" case */
10881047
1089- /* might be a sub directory in an excluded directory */
1090- if (!exclude ) {
1091- struct path_exclude_check check ;
1092- int dt = DT_DIR ;
1093- path_exclude_check_init (& check , dir );
1094- exclude = is_path_excluded (& check , dirname , len , & dt );
1095- path_exclude_check_clear (& check );
1096- }
1097-
10981048 /*
10991049 * We are looking for ignored files and our directory is not ignored,
11001050 * check if it contains untracked files (i.e. is listed as untracked)
@@ -1129,27 +1079,13 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
11291079 *
11301080 * Return 1 for exclude, 0 for include.
11311081 */
1132- static int treat_file (struct dir_struct * dir , struct strbuf * path , int exclude , int * dtype )
1082+ static int treat_file (struct dir_struct * dir , struct strbuf * path , int exclude )
11331083{
1134- struct path_exclude_check check ;
1135- int exclude_file = 0 ;
1136-
11371084 /* Always exclude indexed files */
11381085 if (index_name_exists (& the_index , path -> buf , path -> len , ignore_case ))
11391086 return 1 ;
11401087
1141- if (exclude )
1142- exclude_file = !(dir -> flags & DIR_SHOW_IGNORED );
1143- else if (dir -> flags & DIR_SHOW_IGNORED ) {
1144- path_exclude_check_init (& check , dir );
1145-
1146- if (!is_path_excluded (& check , path -> buf , path -> len , dtype ))
1147- exclude_file = 1 ;
1148-
1149- path_exclude_check_clear (& check );
1150- }
1151-
1152- return exclude_file ;
1088+ return exclude == !(dir -> flags & DIR_SHOW_IGNORED );
11531089}
11541090
11551091/*
@@ -1306,12 +1242,9 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
13061242 break ;
13071243 case DT_REG :
13081244 case DT_LNK :
1309- switch (treat_file (dir , path , exclude , & dtype )) {
1310- case 1 :
1245+ if (treat_file (dir , path , exclude ))
13111246 return path_ignored ;
1312- default :
1313- break ;
1314- }
1247+ break ;
13151248 }
13161249 return path_handled ;
13171250}
0 commit comments