@@ -602,27 +602,27 @@ void parse_exclude_pattern(const char **pattern,
602
602
void add_exclude (const char * string , const char * base ,
603
603
int baselen , struct exclude_list * el , int srcpos )
604
604
{
605
- struct exclude * x ;
605
+ struct path_pattern * pattern ;
606
606
int patternlen ;
607
607
unsigned flags ;
608
608
int nowildcardlen ;
609
609
610
610
parse_exclude_pattern (& string , & patternlen , & flags , & nowildcardlen );
611
611
if (flags & EXC_FLAG_MUSTBEDIR ) {
612
- FLEXPTR_ALLOC_MEM (x , pattern , string , patternlen );
612
+ FLEXPTR_ALLOC_MEM (pattern , pattern , string , patternlen );
613
613
} else {
614
- x = xmalloc (sizeof (* x ));
615
- x -> pattern = string ;
614
+ pattern = xmalloc (sizeof (* pattern ));
615
+ pattern -> pattern = string ;
616
616
}
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 ;
626
626
}
627
627
628
628
static int read_skip_worktree_file_from_index (const struct index_state * istate ,
@@ -651,8 +651,8 @@ void clear_exclude_list(struct exclude_list *el)
651
651
int i ;
652
652
653
653
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 );
656
656
free (el -> filebuf );
657
657
658
658
memset (el , 0 , sizeof (* el ));
@@ -1021,51 +1021,54 @@ int match_pathname(const char *pathname, int pathlen,
1021
1021
* any, determines the fate. Returns the exclude_list element which
1022
1022
* matched, or NULL for undecided.
1023
1023
*/
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 ,
1025
1025
int pathlen ,
1026
1026
const char * basename ,
1027
1027
int * dtype ,
1028
1028
struct exclude_list * el ,
1029
1029
struct index_state * istate )
1030
1030
{
1031
- struct exclude * exc = NULL ; /* undecided */
1031
+ struct path_pattern * res = NULL ; /* undecided */
1032
1032
int i ;
1033
1033
1034
1034
if (!el -> nr )
1035
1035
return NULL ; /* undefined */
1036
1036
1037
1037
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 ;
1041
1041
1042
- if (x -> flags & EXC_FLAG_MUSTBEDIR ) {
1042
+ if (pattern -> flags & EXC_FLAG_MUSTBEDIR ) {
1043
1043
if (* dtype == DT_UNKNOWN )
1044
1044
* dtype = get_dtype (NULL , istate , pathname , pathlen );
1045
1045
if (* dtype != DT_DIR )
1046
1046
continue ;
1047
1047
}
1048
1048
1049
- if (x -> flags & EXC_FLAG_NODIR ) {
1049
+ if (pattern -> flags & EXC_FLAG_NODIR ) {
1050
1050
if (match_basename (basename ,
1051
1051
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 ;
1055
1055
break ;
1056
1056
}
1057
1057
continue ;
1058
1058
}
1059
1059
1060
- assert (x -> baselen == 0 || x -> base [x -> baselen - 1 ] == '/' );
1060
+ assert (pattern -> baselen == 0 ||
1061
+ pattern -> base [pattern -> baselen - 1 ] == '/' );
1061
1062
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 ;
1065
1068
break ;
1066
1069
}
1067
1070
}
1068
- return exc ;
1071
+ return res ;
1069
1072
}
1070
1073
1071
1074
/*
@@ -1076,30 +1079,30 @@ int is_excluded_from_list(const char *pathname,
1076
1079
int pathlen , const char * basename , int * dtype ,
1077
1080
struct exclude_list * el , struct index_state * istate )
1078
1081
{
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 ,
1081
1084
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 ;
1084
1087
return -1 ; /* undecided */
1085
1088
}
1086
1089
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 )
1091
1094
{
1092
1095
int i , j ;
1093
1096
struct exclude_list_group * group ;
1094
- struct exclude * exclude ;
1097
+ struct path_pattern * pattern ;
1095
1098
for (i = EXC_CMDL ; i <= EXC_FILE ; i ++ ) {
1096
1099
group = & dir -> exclude_list_group [i ];
1097
1100
for (j = group -> nr - 1 ; j >= 0 ; j -- ) {
1098
- exclude = last_exclude_matching_from_list (
1101
+ pattern = last_exclude_matching_from_list (
1099
1102
pathname , pathlen , basename , dtype_p ,
1100
1103
& group -> el [j ], istate );
1101
- if (exclude )
1102
- return exclude ;
1104
+ if (pattern )
1105
+ return pattern ;
1103
1106
}
1104
1107
}
1105
1108
return NULL ;
@@ -1132,15 +1135,15 @@ static void prep_exclude(struct dir_struct *dir,
1132
1135
break ;
1133
1136
el = & group -> el [dir -> exclude_stack -> exclude_ix ];
1134
1137
dir -> exclude_stack = stk -> prev ;
1135
- dir -> exclude = NULL ;
1138
+ dir -> pattern = NULL ;
1136
1139
free ((char * )el -> src ); /* see strbuf_detach() below */
1137
1140
clear_exclude_list (el );
1138
1141
free (stk );
1139
1142
group -> nr -- ;
1140
1143
}
1141
1144
1142
1145
/* Skip traversing into sub directories if the parent is excluded */
1143
- if (dir -> exclude )
1146
+ if (dir -> pattern )
1144
1147
return ;
1145
1148
1146
1149
/*
@@ -1189,15 +1192,15 @@ static void prep_exclude(struct dir_struct *dir,
1189
1192
if (stk -> baselen ) {
1190
1193
int dt = DT_DIR ;
1191
1194
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 ,
1193
1196
istate ,
1194
1197
dir -> basebuf .buf , stk -> baselen - 1 ,
1195
1198
dir -> basebuf .buf + current , & dt );
1196
1199
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 ) {
1201
1204
dir -> exclude_stack = stk ;
1202
1205
return ;
1203
1206
}
@@ -1223,7 +1226,7 @@ static void prep_exclude(struct dir_struct *dir,
1223
1226
/*
1224
1227
* dir->basebuf gets reused by the traversal, but we
1225
1228
* need fname to remain unchanged to ensure the src
1226
- * member of each struct exclude correctly
1229
+ * member of each struct path_pattern correctly
1227
1230
* back-references its source file. Other invocations
1228
1231
* of add_exclude_list provide stable strings, so we
1229
1232
* strbuf_detach() and free() here in the caller.
@@ -1266,7 +1269,7 @@ static void prep_exclude(struct dir_struct *dir,
1266
1269
* Returns the exclude_list element which matched, or NULL for
1267
1270
* undecided.
1268
1271
*/
1269
- struct exclude * last_exclude_matching (struct dir_struct * dir ,
1272
+ struct path_pattern * last_exclude_matching (struct dir_struct * dir ,
1270
1273
struct index_state * istate ,
1271
1274
const char * pathname ,
1272
1275
int * dtype_p )
@@ -1277,8 +1280,8 @@ struct exclude *last_exclude_matching(struct dir_struct *dir,
1277
1280
1278
1281
prep_exclude (dir , istate , pathname , basename - pathname );
1279
1282
1280
- if (dir -> exclude )
1281
- return dir -> exclude ;
1283
+ if (dir -> pattern )
1284
+ return dir -> pattern ;
1282
1285
1283
1286
return last_exclude_matching_from_lists (dir , istate , pathname , pathlen ,
1284
1287
basename , dtype_p );
@@ -1292,10 +1295,10 @@ struct exclude *last_exclude_matching(struct dir_struct *dir,
1292
1295
int is_excluded (struct dir_struct * dir , struct index_state * istate ,
1293
1296
const char * pathname , int * dtype_p )
1294
1297
{
1295
- struct exclude * exclude =
1298
+ struct path_pattern * pattern =
1296
1299
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 ;
1299
1302
return 0 ;
1300
1303
}
1301
1304
0 commit comments