@@ -602,27 +602,27 @@ void parse_exclude_pattern(const char **pattern,
602602void add_exclude (const char * string , const char * base ,
603603 int baselen , struct exclude_list * el , int srcpos )
604604{
605- struct exclude * x ;
605+ struct path_pattern * pattern ;
606606 int patternlen ;
607607 unsigned flags ;
608608 int nowildcardlen ;
609609
610610 parse_exclude_pattern (& string , & patternlen , & flags , & nowildcardlen );
611611 if (flags & EXC_FLAG_MUSTBEDIR ) {
612- FLEXPTR_ALLOC_MEM (x , pattern , string , patternlen );
612+ FLEXPTR_ALLOC_MEM (pattern , pattern , string , patternlen );
613613 } else {
614- x = xmalloc (sizeof (* x ));
615- x -> pattern = string ;
614+ pattern = xmalloc (sizeof (* pattern ));
615+ pattern -> pattern = string ;
616616 }
617- x -> patternlen = patternlen ;
618- x -> nowildcardlen = nowildcardlen ;
619- x -> base = base ;
620- x -> baselen = baselen ;
621- x -> flags = flags ;
622- x -> srcpos = srcpos ;
623- ALLOC_GROW (el -> excludes , el -> nr + 1 , el -> alloc );
624- el -> excludes [el -> nr ++ ] = x ;
625- x -> el = el ;
617+ pattern -> patternlen = patternlen ;
618+ pattern -> nowildcardlen = nowildcardlen ;
619+ pattern -> base = base ;
620+ pattern -> baselen = baselen ;
621+ pattern -> flags = flags ;
622+ pattern -> srcpos = srcpos ;
623+ ALLOC_GROW (el -> patterns , el -> nr + 1 , el -> alloc );
624+ el -> patterns [el -> nr ++ ] = pattern ;
625+ pattern -> el = el ;
626626}
627627
628628static int read_skip_worktree_file_from_index (const struct index_state * istate ,
@@ -651,8 +651,8 @@ void clear_exclude_list(struct exclude_list *el)
651651 int i ;
652652
653653 for (i = 0 ; i < el -> nr ; i ++ )
654- free (el -> excludes [i ]);
655- free (el -> excludes );
654+ free (el -> patterns [i ]);
655+ free (el -> patterns );
656656 free (el -> filebuf );
657657
658658 memset (el , 0 , sizeof (* el ));
@@ -1021,51 +1021,54 @@ int match_pathname(const char *pathname, int pathlen,
10211021 * any, determines the fate. Returns the exclude_list element which
10221022 * matched, or NULL for undecided.
10231023 */
1024- static struct exclude * last_exclude_matching_from_list (const char * pathname ,
1024+ static struct path_pattern * last_exclude_matching_from_list (const char * pathname ,
10251025 int pathlen ,
10261026 const char * basename ,
10271027 int * dtype ,
10281028 struct exclude_list * el ,
10291029 struct index_state * istate )
10301030{
1031- struct exclude * exc = NULL ; /* undecided */
1031+ struct path_pattern * res = NULL ; /* undecided */
10321032 int i ;
10331033
10341034 if (!el -> nr )
10351035 return NULL ; /* undefined */
10361036
10371037 for (i = el -> nr - 1 ; 0 <= i ; i -- ) {
1038- struct exclude * x = el -> excludes [i ];
1039- const char * exclude = x -> pattern ;
1040- int prefix = x -> nowildcardlen ;
1038+ struct path_pattern * pattern = el -> patterns [i ];
1039+ const char * exclude = pattern -> pattern ;
1040+ int prefix = pattern -> nowildcardlen ;
10411041
1042- if (x -> flags & EXC_FLAG_MUSTBEDIR ) {
1042+ if (pattern -> flags & EXC_FLAG_MUSTBEDIR ) {
10431043 if (* dtype == DT_UNKNOWN )
10441044 * dtype = get_dtype (NULL , istate , pathname , pathlen );
10451045 if (* dtype != DT_DIR )
10461046 continue ;
10471047 }
10481048
1049- if (x -> flags & EXC_FLAG_NODIR ) {
1049+ if (pattern -> flags & EXC_FLAG_NODIR ) {
10501050 if (match_basename (basename ,
10511051 pathlen - (basename - pathname ),
1052- exclude , prefix , x -> patternlen ,
1053- x -> flags )) {
1054- exc = x ;
1052+ exclude , prefix , pattern -> patternlen ,
1053+ pattern -> flags )) {
1054+ res = pattern ;
10551055 break ;
10561056 }
10571057 continue ;
10581058 }
10591059
1060- assert (x -> baselen == 0 || x -> base [x -> baselen - 1 ] == '/' );
1060+ assert (pattern -> baselen == 0 ||
1061+ pattern -> base [pattern -> baselen - 1 ] == '/' );
10611062 if (match_pathname (pathname , pathlen ,
1062- x -> base , x -> baselen ? x -> baselen - 1 : 0 ,
1063- exclude , prefix , x -> patternlen , x -> flags )) {
1064- exc = x ;
1063+ pattern -> base ,
1064+ pattern -> baselen ? pattern -> baselen - 1 : 0 ,
1065+ exclude , prefix , pattern -> patternlen ,
1066+ pattern -> flags )) {
1067+ res = pattern ;
10651068 break ;
10661069 }
10671070 }
1068- return exc ;
1071+ return res ;
10691072}
10701073
10711074/*
@@ -1076,30 +1079,30 @@ int is_excluded_from_list(const char *pathname,
10761079 int pathlen , const char * basename , int * dtype ,
10771080 struct exclude_list * el , struct index_state * istate )
10781081{
1079- struct exclude * exclude ;
1080- exclude = last_exclude_matching_from_list (pathname , pathlen , basename ,
1082+ struct path_pattern * pattern ;
1083+ pattern = last_exclude_matching_from_list (pathname , pathlen , basename ,
10811084 dtype , el , istate );
1082- if (exclude )
1083- return exclude -> flags & EXC_FLAG_NEGATIVE ? 0 : 1 ;
1085+ if (pattern )
1086+ return pattern -> flags & EXC_FLAG_NEGATIVE ? 0 : 1 ;
10841087 return -1 ; /* undecided */
10851088}
10861089
1087- static struct exclude * last_exclude_matching_from_lists (struct dir_struct * dir ,
1088- struct index_state * istate ,
1089- const char * pathname , int pathlen , const char * basename ,
1090- int * dtype_p )
1090+ static struct path_pattern * last_exclude_matching_from_lists (
1091+ struct dir_struct * dir , struct index_state * istate ,
1092+ const char * pathname , int pathlen ,
1093+ const char * basename , int * dtype_p )
10911094{
10921095 int i , j ;
10931096 struct exclude_list_group * group ;
1094- struct exclude * exclude ;
1097+ struct path_pattern * pattern ;
10951098 for (i = EXC_CMDL ; i <= EXC_FILE ; i ++ ) {
10961099 group = & dir -> exclude_list_group [i ];
10971100 for (j = group -> nr - 1 ; j >= 0 ; j -- ) {
1098- exclude = last_exclude_matching_from_list (
1101+ pattern = last_exclude_matching_from_list (
10991102 pathname , pathlen , basename , dtype_p ,
11001103 & group -> el [j ], istate );
1101- if (exclude )
1102- return exclude ;
1104+ if (pattern )
1105+ return pattern ;
11031106 }
11041107 }
11051108 return NULL ;
@@ -1132,15 +1135,15 @@ static void prep_exclude(struct dir_struct *dir,
11321135 break ;
11331136 el = & group -> el [dir -> exclude_stack -> exclude_ix ];
11341137 dir -> exclude_stack = stk -> prev ;
1135- dir -> exclude = NULL ;
1138+ dir -> pattern = NULL ;
11361139 free ((char * )el -> src ); /* see strbuf_detach() below */
11371140 clear_exclude_list (el );
11381141 free (stk );
11391142 group -> nr -- ;
11401143 }
11411144
11421145 /* Skip traversing into sub directories if the parent is excluded */
1143- if (dir -> exclude )
1146+ if (dir -> pattern )
11441147 return ;
11451148
11461149 /*
@@ -1189,15 +1192,15 @@ static void prep_exclude(struct dir_struct *dir,
11891192 if (stk -> baselen ) {
11901193 int dt = DT_DIR ;
11911194 dir -> basebuf .buf [stk -> baselen - 1 ] = 0 ;
1192- dir -> exclude = last_exclude_matching_from_lists (dir ,
1195+ dir -> pattern = last_exclude_matching_from_lists (dir ,
11931196 istate ,
11941197 dir -> basebuf .buf , stk -> baselen - 1 ,
11951198 dir -> basebuf .buf + current , & dt );
11961199 dir -> basebuf .buf [stk -> baselen - 1 ] = '/' ;
1197- if (dir -> exclude &&
1198- dir -> exclude -> flags & EXC_FLAG_NEGATIVE )
1199- dir -> exclude = NULL ;
1200- if (dir -> exclude ) {
1200+ if (dir -> pattern &&
1201+ dir -> pattern -> flags & EXC_FLAG_NEGATIVE )
1202+ dir -> pattern = NULL ;
1203+ if (dir -> pattern ) {
12011204 dir -> exclude_stack = stk ;
12021205 return ;
12031206 }
@@ -1223,7 +1226,7 @@ static void prep_exclude(struct dir_struct *dir,
12231226 /*
12241227 * dir->basebuf gets reused by the traversal, but we
12251228 * need fname to remain unchanged to ensure the src
1226- * member of each struct exclude correctly
1229+ * member of each struct path_pattern correctly
12271230 * back-references its source file. Other invocations
12281231 * of add_exclude_list provide stable strings, so we
12291232 * strbuf_detach() and free() here in the caller.
@@ -1266,7 +1269,7 @@ static void prep_exclude(struct dir_struct *dir,
12661269 * Returns the exclude_list element which matched, or NULL for
12671270 * undecided.
12681271 */
1269- struct exclude * last_exclude_matching (struct dir_struct * dir ,
1272+ struct path_pattern * last_exclude_matching (struct dir_struct * dir ,
12701273 struct index_state * istate ,
12711274 const char * pathname ,
12721275 int * dtype_p )
@@ -1277,8 +1280,8 @@ struct exclude *last_exclude_matching(struct dir_struct *dir,
12771280
12781281 prep_exclude (dir , istate , pathname , basename - pathname );
12791282
1280- if (dir -> exclude )
1281- return dir -> exclude ;
1283+ if (dir -> pattern )
1284+ return dir -> pattern ;
12821285
12831286 return last_exclude_matching_from_lists (dir , istate , pathname , pathlen ,
12841287 basename , dtype_p );
@@ -1292,10 +1295,10 @@ struct exclude *last_exclude_matching(struct dir_struct *dir,
12921295int is_excluded (struct dir_struct * dir , struct index_state * istate ,
12931296 const char * pathname , int * dtype_p )
12941297{
1295- struct exclude * exclude =
1298+ struct path_pattern * pattern =
12961299 last_exclude_matching (dir , istate , pathname , dtype_p );
1297- if (exclude )
1298- return exclude -> flags & EXC_FLAG_NEGATIVE ? 0 : 1 ;
1300+ if (pattern )
1301+ return pattern -> flags & EXC_FLAG_NEGATIVE ? 0 : 1 ;
12991302 return 0 ;
13001303}
13011304
0 commit comments