@@ -53,8 +53,6 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
53
53
int check_only , const struct path_simplify * simplify );
54
54
static int get_dtype (struct dirent * de , const char * path , int len );
55
55
56
- static struct trace_key trace_exclude = TRACE_KEY_INIT (EXCLUDE );
57
-
58
56
/* helper string functions with support for the ignore_case flag */
59
57
int strcmp_icase (const char * a , const char * b )
60
58
{
@@ -516,7 +514,6 @@ void add_exclude(const char *string, const char *base,
516
514
x -> baselen = baselen ;
517
515
x -> flags = flags ;
518
516
x -> srcpos = srcpos ;
519
- string_list_init (& x -> sticky_paths , 1 );
520
517
ALLOC_GROW (el -> excludes , el -> nr + 1 , el -> alloc );
521
518
el -> excludes [el -> nr ++ ] = x ;
522
519
x -> el = el ;
@@ -557,10 +554,8 @@ void clear_exclude_list(struct exclude_list *el)
557
554
{
558
555
int i ;
559
556
560
- for (i = 0 ; i < el -> nr ; i ++ ) {
561
- string_list_clear (& el -> excludes [i ]-> sticky_paths , 0 );
557
+ for (i = 0 ; i < el -> nr ; i ++ )
562
558
free (el -> excludes [i ]);
563
- }
564
559
free (el -> excludes );
565
560
free (el -> filebuf );
566
561
@@ -875,7 +870,7 @@ int match_pathname(const char *pathname, int pathlen,
875
870
* then our prefix match is all we need; we
876
871
* do not need to call fnmatch at all.
877
872
*/
878
- if (!patternlen && ( !namelen || * name == '/' ) )
873
+ if (!patternlen && !namelen )
879
874
return 1 ;
880
875
}
881
876
@@ -884,113 +879,6 @@ int match_pathname(const char *pathname, int pathlen,
884
879
WM_PATHNAME ) == 0 ;
885
880
}
886
881
887
- static void add_sticky (struct exclude * exc , const char * pathname , int pathlen )
888
- {
889
- struct strbuf sb = STRBUF_INIT ;
890
- int i ;
891
-
892
- for (i = exc -> sticky_paths .nr - 1 ; i >= 0 ; i -- ) {
893
- const char * sticky = exc -> sticky_paths .items [i ].string ;
894
- int len = strlen (sticky );
895
-
896
- if (pathlen < len && sticky [pathlen ] == '/' &&
897
- !strncmp (pathname , sticky , pathlen ))
898
- return ;
899
- }
900
-
901
- strbuf_add (& sb , pathname , pathlen );
902
- string_list_append_nodup (& exc -> sticky_paths , strbuf_detach (& sb , NULL ));
903
- }
904
-
905
- static int match_sticky (struct exclude * exc , const char * pathname , int pathlen , int dtype )
906
- {
907
- int i ;
908
-
909
- for (i = exc -> sticky_paths .nr - 1 ; i >= 0 ; i -- ) {
910
- const char * sticky = exc -> sticky_paths .items [i ].string ;
911
- int len = strlen (sticky );
912
-
913
- if (pathlen == len && dtype == DT_DIR &&
914
- !strncmp (pathname , sticky , len ))
915
- return 1 ;
916
-
917
- if (pathlen > len && pathname [len ] == '/' &&
918
- !strncmp (pathname , sticky , len ))
919
- return 1 ;
920
- }
921
-
922
- return 0 ;
923
- }
924
-
925
- static inline int different_decisions (const struct exclude * a ,
926
- const struct exclude * b )
927
- {
928
- return (a -> flags & EXC_FLAG_NEGATIVE ) != (b -> flags & EXC_FLAG_NEGATIVE );
929
- }
930
-
931
- /*
932
- * Return non-zero if pathname is a directory and an ancestor of the
933
- * literal path in a pattern.
934
- */
935
- static int match_directory_part (const char * pathname , int pathlen ,
936
- int * dtype , struct exclude * x )
937
- {
938
- const char * base = x -> base ;
939
- int baselen = x -> baselen ? x -> baselen - 1 : 0 ;
940
- const char * pattern = x -> pattern ;
941
- int prefix = x -> nowildcardlen ;
942
- int patternlen = x -> patternlen ;
943
-
944
- if (* dtype == DT_UNKNOWN )
945
- * dtype = get_dtype (NULL , pathname , pathlen );
946
- if (* dtype != DT_DIR )
947
- return 0 ;
948
-
949
- if (* pattern == '/' ) {
950
- pattern ++ ;
951
- patternlen -- ;
952
- prefix -- ;
953
- }
954
-
955
- if (baselen ) {
956
- if (((pathlen < baselen && base [pathlen ] == '/' ) ||
957
- pathlen == baselen ) &&
958
- !strncmp_icase (pathname , base , pathlen ))
959
- return 1 ;
960
- pathname += baselen + 1 ;
961
- pathlen -= baselen + 1 ;
962
- }
963
-
964
-
965
- if (prefix &&
966
- (((pathlen < prefix && pattern [pathlen ] == '/' ) ||
967
- pathlen == prefix ) &&
968
- !strncmp_icase (pathname , pattern , pathlen )))
969
- return 1 ;
970
-
971
- return 0 ;
972
- }
973
-
974
- static struct exclude * should_descend (const char * pathname , int pathlen ,
975
- int * dtype , struct exclude_list * el ,
976
- struct exclude * exc )
977
- {
978
- int i ;
979
-
980
- for (i = el -> nr - 1 ; 0 <= i ; i -- ) {
981
- struct exclude * x = el -> excludes [i ];
982
-
983
- if (x == exc )
984
- break ;
985
-
986
- if (!(x -> flags & EXC_FLAG_NODIR ) &&
987
- different_decisions (x , exc ) &&
988
- match_directory_part (pathname , pathlen , dtype , x ))
989
- return x ;
990
- }
991
- return NULL ;
992
- }
993
-
994
882
/*
995
883
* Scan the given exclude list in reverse to see whether pathname
996
884
* should be ignored. The first match (i.e. the last on the list), if
@@ -1004,32 +892,16 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
1004
892
struct exclude_list * el )
1005
893
{
1006
894
struct exclude * exc = NULL ; /* undecided */
1007
- int i , maybe_descend = 0 ;
895
+ int i ;
1008
896
1009
897
if (!el -> nr )
1010
898
return NULL ; /* undefined */
1011
899
1012
- trace_printf_key (& trace_exclude , "exclude: from %s\n" , el -> src );
1013
-
1014
900
for (i = el -> nr - 1 ; 0 <= i ; i -- ) {
1015
901
struct exclude * x = el -> excludes [i ];
1016
902
const char * exclude = x -> pattern ;
1017
903
int prefix = x -> nowildcardlen ;
1018
904
1019
- if (!maybe_descend && i < el -> nr - 1 &&
1020
- different_decisions (x , el -> excludes [i + 1 ]))
1021
- maybe_descend = 1 ;
1022
-
1023
- if (x -> sticky_paths .nr ) {
1024
- if (* dtype == DT_UNKNOWN )
1025
- * dtype = get_dtype (NULL , pathname , pathlen );
1026
- if (match_sticky (x , pathname , pathlen , * dtype )) {
1027
- exc = x ;
1028
- break ;
1029
- }
1030
- continue ;
1031
- }
1032
-
1033
905
if (x -> flags & EXC_FLAG_MUSTBEDIR ) {
1034
906
if (* dtype == DT_UNKNOWN )
1035
907
* dtype = get_dtype (NULL , pathname , pathlen );
@@ -1056,45 +928,6 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
1056
928
break ;
1057
929
}
1058
930
}
1059
-
1060
- if (!exc ) {
1061
- trace_printf_key (& trace_exclude , "exclude: %.*s => n/a\n" ,
1062
- pathlen , pathname );
1063
- return NULL ;
1064
- }
1065
-
1066
- /*
1067
- * We have found a matching pattern "exc" that may exclude whole
1068
- * directory. We also found that there may be a pattern that matches
1069
- * something inside the directory and reincludes stuff.
1070
- *
1071
- * Go through the patterns again, find that pattern and double check.
1072
- * If it's true, return "undecided" and keep descending in. "exc" is
1073
- * marked sticky so that it continues to match inside the directory.
1074
- */
1075
- if (!(exc -> flags & EXC_FLAG_NEGATIVE ) && maybe_descend ) {
1076
- struct exclude * x ;
1077
-
1078
- if (* dtype == DT_UNKNOWN )
1079
- * dtype = get_dtype (NULL , pathname , pathlen );
1080
-
1081
- if (* dtype == DT_DIR &&
1082
- (x = should_descend (pathname , pathlen , dtype , el , exc ))) {
1083
- add_sticky (exc , pathname , pathlen );
1084
- trace_printf_key (& trace_exclude ,
1085
- "exclude: %.*s vs %s at line %d => %s,"
1086
- " forced open by %s at line %d => n/a\n" ,
1087
- pathlen , pathname , exc -> pattern , exc -> srcpos ,
1088
- exc -> flags & EXC_FLAG_NEGATIVE ? "no" : "yes" ,
1089
- x -> pattern , x -> srcpos );
1090
- return NULL ;
1091
- }
1092
- }
1093
-
1094
- trace_printf_key (& trace_exclude , "exclude: %.*s vs %s at line %d => %s%s\n" ,
1095
- pathlen , pathname , exc -> pattern , exc -> srcpos ,
1096
- exc -> flags & EXC_FLAG_NEGATIVE ? "no" : "yes" ,
1097
- exc -> sticky_paths .nr ? " (stuck)" : "" );
1098
931
return exc ;
1099
932
}
1100
933
@@ -1840,13 +1673,9 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
1840
1673
struct cached_dir cdir ;
1841
1674
enum path_treatment state , subdir_state , dir_state = path_none ;
1842
1675
struct strbuf path = STRBUF_INIT ;
1843
- static int level = 0 ;
1844
1676
1845
1677
strbuf_add (& path , base , baselen );
1846
1678
1847
- trace_printf_key (& trace_exclude , "exclude: [%d] enter '%.*s'\n" ,
1848
- level ++ , baselen , base );
1849
-
1850
1679
if (open_cached_dir (& cdir , dir , untracked , & path , check_only ))
1851
1680
goto out ;
1852
1681
@@ -1910,8 +1739,6 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
1910
1739
}
1911
1740
close_cached_dir (& cdir );
1912
1741
out :
1913
- trace_printf_key (& trace_exclude , "exclude: [%d] leave '%.*s'\n" ,
1914
- -- level , baselen , base );
1915
1742
strbuf_release (& path );
1916
1743
1917
1744
return dir_state ;
@@ -2148,25 +1975,6 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
2148
1975
return root ;
2149
1976
}
2150
1977
2151
- static void clear_sticky (struct dir_struct * dir )
2152
- {
2153
- struct exclude_list_group * g ;
2154
- struct exclude_list * el ;
2155
- struct exclude * x ;
2156
- int i , j , k ;
2157
-
2158
- for (i = EXC_CMDL ; i <= EXC_FILE ; i ++ ) {
2159
- g = & dir -> exclude_list_group [i ];
2160
- for (j = g -> nr - 1 ; j >= 0 ; j -- ) {
2161
- el = & g -> el [j ];
2162
- for (k = el -> nr - 1 ; 0 <= k ; k -- ) {
2163
- x = el -> excludes [k ];
2164
- string_list_clear (& x -> sticky_paths , 0 );
2165
- }
2166
- }
2167
- }
2168
- }
2169
-
2170
1978
int read_directory (struct dir_struct * dir , const char * path , int len , const struct pathspec * pathspec )
2171
1979
{
2172
1980
struct path_simplify * simplify ;
@@ -2187,12 +1995,6 @@ int read_directory(struct dir_struct *dir, const char *path, int len, const stru
2187
1995
if (has_symlink_leading_path (path , len ))
2188
1996
return dir -> nr ;
2189
1997
2190
- /*
2191
- * Stay on the safe side. if read_directory() has run once on
2192
- * "dir", some sticky flag may have been left. Clear them all.
2193
- */
2194
- clear_sticky (dir );
2195
-
2196
1998
/*
2197
1999
* exclude patterns are treated like positive ones in
2198
2000
* create_simplify. Usually exclude patterns should be a
0 commit comments