@@ -1016,17 +1016,17 @@ static int match_wildcard_base(const struct pathspec_item *item,
1016
1016
/*
1017
1017
* Is a tree entry interesting given the pathspec we have?
1018
1018
*
1019
- * Pre-condition: either baselen == base_offset (i.e. empty path)
1019
+ * Pre-condition: either baselen == 0 (i.e. empty path)
1020
1020
* or base[baselen-1] == '/' (i.e. with trailing slash).
1021
1021
*/
1022
1022
static enum interesting do_match (struct index_state * istate ,
1023
1023
const struct name_entry * entry ,
1024
- struct strbuf * base , int base_offset ,
1024
+ struct strbuf * base ,
1025
1025
const struct pathspec * ps ,
1026
1026
int exclude )
1027
1027
{
1028
1028
int i ;
1029
- int pathlen , baselen = base -> len - base_offset ;
1029
+ int pathlen , baselen = base -> len ;
1030
1030
enum interesting never_interesting = ps -> has_wildcard ?
1031
1031
entry_not_interesting : all_entries_not_interesting ;
1032
1032
@@ -1044,7 +1044,7 @@ static enum interesting do_match(struct index_state *istate,
1044
1044
!(ps -> magic & PATHSPEC_MAXDEPTH ) ||
1045
1045
ps -> max_depth == -1 )
1046
1046
return all_entries_interesting ;
1047
- return within_depth (base -> buf + base_offset , baselen ,
1047
+ return within_depth (base -> buf , baselen ,
1048
1048
!!S_ISDIR (entry -> mode ),
1049
1049
ps -> max_depth ) ?
1050
1050
entry_interesting : entry_not_interesting ;
@@ -1055,7 +1055,7 @@ static enum interesting do_match(struct index_state *istate,
1055
1055
for (i = ps -> nr - 1 ; i >= 0 ; i -- ) {
1056
1056
const struct pathspec_item * item = ps -> items + i ;
1057
1057
const char * match = item -> match ;
1058
- const char * base_str = base -> buf + base_offset ;
1058
+ const char * base_str = base -> buf ;
1059
1059
int matchlen = item -> len , matched = 0 ;
1060
1060
1061
1061
if ((!exclude && item -> magic & PATHSPEC_EXCLUDE ) ||
@@ -1148,9 +1148,9 @@ static enum interesting do_match(struct index_state *istate,
1148
1148
1149
1149
strbuf_add (base , entry -> path , pathlen );
1150
1150
1151
- if (!git_fnmatch (item , match , base -> buf + base_offset ,
1151
+ if (!git_fnmatch (item , match , base -> buf ,
1152
1152
item -> nowildcard_len )) {
1153
- strbuf_setlen (base , base_offset + baselen );
1153
+ strbuf_setlen (base , baselen );
1154
1154
goto interesting ;
1155
1155
}
1156
1156
@@ -1162,13 +1162,13 @@ static enum interesting do_match(struct index_state *istate,
1162
1162
* be performed in the submodule itself.
1163
1163
*/
1164
1164
if (ps -> recurse_submodules && S_ISGITLINK (entry -> mode ) &&
1165
- !ps_strncmp (item , match , base -> buf + base_offset ,
1165
+ !ps_strncmp (item , match , base -> buf ,
1166
1166
item -> nowildcard_len )) {
1167
- strbuf_setlen (base , base_offset + baselen );
1167
+ strbuf_setlen (base , baselen );
1168
1168
goto interesting ;
1169
1169
}
1170
1170
1171
- strbuf_setlen (base , base_offset + baselen );
1171
+ strbuf_setlen (base , baselen );
1172
1172
1173
1173
/*
1174
1174
* Match all directories. We'll try to match files
@@ -1204,9 +1204,9 @@ static enum interesting do_match(struct index_state *istate,
1204
1204
return entry_interesting ;
1205
1205
1206
1206
strbuf_add (base , entry -> path , pathlen );
1207
- ret = match_pathspec_attrs (istate , base -> buf + base_offset ,
1208
- base -> len - base_offset , item );
1209
- strbuf_setlen (base , base_offset + baselen );
1207
+ ret = match_pathspec_attrs (istate , base -> buf ,
1208
+ base -> len , item );
1209
+ strbuf_setlen (base , baselen );
1210
1210
if (!ret )
1211
1211
continue ;
1212
1212
}
@@ -1218,7 +1218,7 @@ static enum interesting do_match(struct index_state *istate,
1218
1218
/*
1219
1219
* Is a tree entry interesting given the pathspec we have?
1220
1220
*
1221
- * Pre-condition: either baselen == base_offset (i.e. empty path)
1221
+ * Pre-condition: either baselen == 0 (i.e. empty path)
1222
1222
* or base[baselen-1] == '/' (i.e. with trailing slash).
1223
1223
*/
1224
1224
enum interesting tree_entry_interesting (struct index_state * istate ,
@@ -1227,8 +1227,7 @@ enum interesting tree_entry_interesting(struct index_state *istate,
1227
1227
const struct pathspec * ps )
1228
1228
{
1229
1229
enum interesting positive , negative ;
1230
- const int base_offset = 0 ;
1231
- positive = do_match (istate , entry , base , base_offset , ps , 0 );
1230
+ positive = do_match (istate , entry , base , ps , 0 );
1232
1231
1233
1232
/*
1234
1233
* case | entry | positive | negative | result
@@ -1265,7 +1264,7 @@ enum interesting tree_entry_interesting(struct index_state *istate,
1265
1264
positive <= entry_not_interesting ) /* #1, #2, #11, #12 */
1266
1265
return positive ;
1267
1266
1268
- negative = do_match (istate , entry , base , base_offset , ps , 1 );
1267
+ negative = do_match (istate , entry , base , ps , 1 );
1269
1268
1270
1269
/* #8, #18 */
1271
1270
if (positive == all_entries_interesting &&
0 commit comments