@@ -53,6 +53,8 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
5353 int check_only , const struct path_simplify * simplify );
5454static int get_dtype (struct dirent * de , const char * path , int len );
5555
56+ static struct trace_key trace_exclude = TRACE_KEY_INIT (EXCLUDE );
57+
5658/* helper string functions with support for the ignore_case flag */
5759int strcmp_icase (const char * a , const char * b )
5860{
@@ -905,6 +907,8 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
905907 if (!el -> nr )
906908 return NULL ; /* undefined */
907909
910+ trace_printf_key (& trace_exclude , "exclude: from %s\n" , el -> src );
911+
908912 for (i = el -> nr - 1 ; 0 <= i ; i -- ) {
909913 struct exclude * x = el -> excludes [i ];
910914 const char * exclude = x -> pattern ;
@@ -936,6 +940,16 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
936940 break ;
937941 }
938942 }
943+
944+ if (!exc ) {
945+ trace_printf_key (& trace_exclude , "exclude: %.*s => n/a\n" ,
946+ pathlen , pathname );
947+ return NULL ;
948+ }
949+
950+ trace_printf_key (& trace_exclude , "exclude: %.*s vs %s at line %d => %s\n" ,
951+ pathlen , pathname , exc -> pattern , exc -> srcpos ,
952+ exc -> flags & EXC_FLAG_NEGATIVE ? "no" : "yes" );
939953 return exc ;
940954}
941955
@@ -1683,9 +1697,13 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
16831697 struct cached_dir cdir ;
16841698 enum path_treatment state , subdir_state , dir_state = path_none ;
16851699 struct strbuf path = STRBUF_INIT ;
1700+ static int level = 0 ;
16861701
16871702 strbuf_add (& path , base , baselen );
16881703
1704+ trace_printf_key (& trace_exclude , "exclude: [%d] enter '%.*s'\n" ,
1705+ level ++ , baselen , base );
1706+
16891707 if (open_cached_dir (& cdir , dir , untracked , & path , check_only ))
16901708 goto out ;
16911709
@@ -1749,6 +1767,8 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
17491767 }
17501768 close_cached_dir (& cdir );
17511769 out :
1770+ trace_printf_key (& trace_exclude , "exclude: [%d] leave '%.*s'\n" ,
1771+ -- level , baselen , base );
17521772 strbuf_release (& path );
17531773
17541774 return dir_state ;
0 commit comments