5 #include "environment.h"
9 #include "read-cache.h"
10 #include "repository.h"
17 * Finds which of the given pathspecs match items in the index.
19 * For each pathspec, sets the corresponding entry in the seen[] array
20 * (which should be specs items long, i.e. the same size as pathspec)
21 * to the nature of the "closest" (i.e. most specific) match found for
22 * that pathspec in the index, if it was a closer type of match than
23 * the existing entry. As an optimization, matching is skipped
24 * altogether if seen[] already only contains non-zero entries.
26 * If seen[] has not already been written to, it may make sense
27 * to use find_pathspecs_matching_against_index() instead.
29 void add_pathspec_matches_against_index(const struct pathspec
*pathspec
,
30 struct index_state
*istate
,
32 enum ps_skip_worktree_action sw_action
)
34 int num_unmatched
= 0, i
;
37 * Since we are walking the index as if we were walking the directory,
38 * we have to mark the matched pathspec as seen; otherwise we will
39 * mistakenly think that the user gave a pathspec that did not match
42 for (i
= 0; i
< pathspec
->nr
; i
++)
47 for (i
= 0; i
< istate
->cache_nr
; i
++) {
48 const struct cache_entry
*ce
= istate
->cache
[i
];
49 if (sw_action
== PS_IGNORE_SKIP_WORKTREE
&&
50 (ce_skip_worktree(ce
) || !path_in_sparse_checkout(ce
->name
, istate
)))
52 ce_path_match(istate
, ce
, pathspec
, seen
);
57 * Finds which of the given pathspecs match items in the index.
59 * This is a one-shot wrapper around add_pathspec_matches_against_index()
60 * which allocates, populates, and returns a seen[] array indicating the
61 * nature of the "closest" (i.e. most specific) matches which each of the
62 * given pathspecs achieves against all items in the index.
64 char *find_pathspecs_matching_against_index(const struct pathspec
*pathspec
,
65 struct index_state
*istate
,
66 enum ps_skip_worktree_action sw_action
)
68 char *seen
= xcalloc(pathspec
->nr
, 1);
69 add_pathspec_matches_against_index(pathspec
, istate
, seen
, sw_action
);
73 char *find_pathspecs_matching_skip_worktree(const struct pathspec
*pathspec
)
75 struct index_state
*istate
= the_repository
->index
;
76 char *seen
= xcalloc(pathspec
->nr
, 1);
79 for (i
= 0; i
< istate
->cache_nr
; i
++) {
80 struct cache_entry
*ce
= istate
->cache
[i
];
81 if (ce_skip_worktree(ce
) || !path_in_sparse_checkout(ce
->name
, istate
))
82 ce_path_match(istate
, ce
, pathspec
, seen
);
91 * Possible future magic semantics include stuff like:
93 * { PATHSPEC_RECURSIVE, '*', "recursive" },
94 * { PATHSPEC_REGEXP, '\0', "regexp" },
98 static struct pathspec_magic
{
100 char mnemonic
; /* this cannot be ':'! */
102 } pathspec_magic
[] = {
103 { PATHSPEC_FROMTOP
, '/', "top" },
104 { PATHSPEC_LITERAL
, '\0', "literal" },
105 { PATHSPEC_GLOB
, '\0', "glob" },
106 { PATHSPEC_ICASE
, '\0', "icase" },
107 { PATHSPEC_EXCLUDE
, '!', "exclude" },
108 { PATHSPEC_ATTR
, '\0', "attr" },
111 static void prefix_magic(struct strbuf
*sb
, int prefixlen
, unsigned magic
)
114 strbuf_addstr(sb
, ":(");
115 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++)
116 if (magic
& pathspec_magic
[i
].bit
) {
117 if (sb
->buf
[sb
->len
- 1] != '(')
118 strbuf_addch(sb
, ',');
119 strbuf_addstr(sb
, pathspec_magic
[i
].name
);
121 strbuf_addf(sb
, ",prefix:%d)", prefixlen
);
124 static size_t strcspn_escaped(const char *s
, const char *stop
)
128 for (i
= s
; *i
; i
++) {
129 /* skip the escaped character */
130 if (i
[0] == '\\' && i
[1]) {
135 if (strchr(stop
, *i
))
141 static inline int invalid_value_char(const char ch
)
143 if (isalnum(ch
) || strchr(",-_", ch
))
148 static char *attr_value_unescape(const char *value
)
153 ret
= xmallocz(strlen(value
));
154 for (src
= value
, dst
= ret
; *src
; src
++, dst
++) {
157 die(_("Escape character '\\' not allowed as "
158 "last character in attr value"));
161 if (invalid_value_char(*src
))
162 die("cannot use '%c' for value matching", *src
);
169 static void parse_pathspec_attr_match(struct pathspec_item
*item
, const char *value
)
171 struct string_list_item
*si
;
172 struct string_list list
= STRING_LIST_INIT_DUP
;
174 if (item
->attr_check
|| item
->attr_match
)
175 die(_("Only one 'attr:' specification is allowed."));
177 if (!value
|| !*value
)
178 die(_("attr spec must not be empty"));
180 string_list_split(&list
, value
, ' ', -1);
181 string_list_remove_empty_items(&list
, 0);
183 item
->attr_check
= attr_check_alloc();
184 CALLOC_ARRAY(item
->attr_match
, list
.nr
);
186 for_each_string_list_item(si
, &list
) {
189 const struct git_attr
*a
;
191 int j
= item
->attr_match_nr
++;
192 const char *attr
= si
->string
;
193 struct attr_match
*am
= &item
->attr_match
[j
];
197 am
->match_mode
= MATCH_UNSPECIFIED
;
199 attr_len
= strlen(attr
);
202 am
->match_mode
= MATCH_UNSET
;
204 attr_len
= strlen(attr
);
207 attr_len
= strcspn(attr
, "=");
208 if (attr
[attr_len
] != '=')
209 am
->match_mode
= MATCH_SET
;
211 const char *v
= &attr
[attr_len
+ 1];
212 am
->match_mode
= MATCH_VALUE
;
213 am
->value
= attr_value_unescape(v
);
218 attr_name
= xmemdupz(attr
, attr_len
);
219 a
= git_attr(attr_name
);
221 die(_("invalid attribute name %s"), attr_name
);
223 attr_check_append(item
->attr_check
, a
);
228 if (item
->attr_check
->nr
!= item
->attr_match_nr
)
229 BUG("should have same number of entries");
231 string_list_clear(&list
, 0);
234 static inline int get_literal_global(void)
236 static int literal
= -1;
239 literal
= git_env_bool(GIT_LITERAL_PATHSPECS_ENVIRONMENT
, 0);
244 static inline int get_glob_global(void)
246 static int glob
= -1;
249 glob
= git_env_bool(GIT_GLOB_PATHSPECS_ENVIRONMENT
, 0);
254 static inline int get_noglob_global(void)
256 static int noglob
= -1;
259 noglob
= git_env_bool(GIT_NOGLOB_PATHSPECS_ENVIRONMENT
, 0);
264 static inline int get_icase_global(void)
266 static int icase
= -1;
269 icase
= git_env_bool(GIT_ICASE_PATHSPECS_ENVIRONMENT
, 0);
274 static int get_global_magic(int element_magic
)
276 int global_magic
= 0;
278 if (get_literal_global())
279 global_magic
|= PATHSPEC_LITERAL
;
281 /* --glob-pathspec is overridden by :(literal) */
282 if (get_glob_global() && !(element_magic
& PATHSPEC_LITERAL
))
283 global_magic
|= PATHSPEC_GLOB
;
285 if (get_glob_global() && get_noglob_global())
286 die(_("global 'glob' and 'noglob' pathspec settings are incompatible"));
288 if (get_icase_global())
289 global_magic
|= PATHSPEC_ICASE
;
291 if ((global_magic
& PATHSPEC_LITERAL
) &&
292 (global_magic
& ~PATHSPEC_LITERAL
))
293 die(_("global 'literal' pathspec setting is incompatible "
294 "with all other global pathspec settings"));
296 /* --noglob-pathspec adds :(literal) _unless_ :(glob) is specified */
297 if (get_noglob_global() && !(element_magic
& PATHSPEC_GLOB
))
298 global_magic
|= PATHSPEC_LITERAL
;
304 * Parse the pathspec element looking for long magic
306 * saves all magic in 'magic'
307 * if prefix magic is used, save the prefix length in 'prefix_len'
308 * returns the position in 'elem' after all magic has been parsed
310 static const char *parse_long_magic(unsigned *magic
, int *prefix_len
,
311 struct pathspec_item
*item
,
317 for (pos
= elem
+ 2; *pos
&& *pos
!= ')'; pos
= nextat
) {
318 size_t len
= strcspn_escaped(pos
, ",)");
322 nextat
= pos
+ len
+ 1; /* handle ',' */
324 nextat
= pos
+ len
; /* handle ')' and '\0' */
329 if (starts_with(pos
, "prefix:")) {
331 *prefix_len
= strtol(pos
+ 7, &endptr
, 10);
332 if (endptr
- pos
!= len
)
333 die(_("invalid parameter for pathspec magic 'prefix'"));
337 if (starts_with(pos
, "attr:")) {
338 char *attr_body
= xmemdupz(pos
+ 5, len
- 5);
339 parse_pathspec_attr_match(item
, attr_body
);
340 *magic
|= PATHSPEC_ATTR
;
345 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
346 if (strlen(pathspec_magic
[i
].name
) == len
&&
347 !strncmp(pathspec_magic
[i
].name
, pos
, len
)) {
348 *magic
|= pathspec_magic
[i
].bit
;
353 if (ARRAY_SIZE(pathspec_magic
) <= i
)
354 die(_("Invalid pathspec magic '%.*s' in '%s'"),
355 (int) len
, pos
, elem
);
359 die(_("Missing ')' at the end of pathspec magic in '%s'"),
367 * Parse the pathspec element looking for short magic
369 * saves all magic in 'magic'
370 * returns the position in 'elem' after all magic has been parsed
372 static const char *parse_short_magic(unsigned *magic
, const char *elem
)
376 for (pos
= elem
+ 1; *pos
&& *pos
!= ':'; pos
++) {
380 /* Special case alias for '!' */
382 *magic
|= PATHSPEC_EXCLUDE
;
386 if (!is_pathspec_magic(ch
))
389 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
390 if (pathspec_magic
[i
].mnemonic
== ch
) {
391 *magic
|= pathspec_magic
[i
].bit
;
396 if (ARRAY_SIZE(pathspec_magic
) <= i
)
397 die(_("Unimplemented pathspec magic '%c' in '%s'"),
407 static const char *parse_element_magic(unsigned *magic
, int *prefix_len
,
408 struct pathspec_item
*item
,
411 if (elem
[0] != ':' || get_literal_global())
412 return elem
; /* nothing to do */
413 else if (elem
[1] == '(')
415 return parse_long_magic(magic
, prefix_len
, item
, elem
);
418 return parse_short_magic(magic
, elem
);
422 * Perform the initialization of a pathspec_item based on a pathspec element.
424 static void init_pathspec_item(struct pathspec_item
*item
, unsigned flags
,
425 const char *prefix
, int prefixlen
,
428 unsigned magic
= 0, element_magic
= 0;
429 const char *copyfrom
= elt
;
431 int pathspec_prefix
= -1;
433 item
->attr_check
= NULL
;
434 item
->attr_match
= NULL
;
435 item
->attr_match_nr
= 0;
437 /* PATHSPEC_LITERAL_PATH ignores magic */
438 if (flags
& PATHSPEC_LITERAL_PATH
) {
439 magic
= PATHSPEC_LITERAL
;
441 copyfrom
= parse_element_magic(&element_magic
,
445 magic
|= element_magic
;
446 magic
|= get_global_magic(element_magic
);
451 if (pathspec_prefix
>= 0 &&
452 (prefixlen
|| (prefix
&& *prefix
)))
453 BUG("'prefix' magic is supposed to be used at worktree's root");
455 if ((magic
& PATHSPEC_LITERAL
) && (magic
& PATHSPEC_GLOB
))
456 die(_("%s: 'literal' and 'glob' are incompatible"), elt
);
458 /* Create match string which will be used for pathspec matching */
459 if (pathspec_prefix
>= 0) {
460 match
= xstrdup(copyfrom
);
461 prefixlen
= pathspec_prefix
;
462 } else if (magic
& PATHSPEC_FROMTOP
) {
463 match
= xstrdup(copyfrom
);
466 match
= prefix_path_gently(prefix
, prefixlen
,
467 &prefixlen
, copyfrom
);
469 const char *hint_path
= get_git_work_tree();
471 hint_path
= get_git_dir();
472 die(_("%s: '%s' is outside repository at '%s'"), elt
,
473 copyfrom
, absolute_path(hint_path
));
478 item
->len
= strlen(item
->match
);
479 item
->prefix
= prefixlen
;
482 * Prefix the pathspec (keep all magic) and assign to
483 * original. Useful for passing to another command.
485 if ((flags
& PATHSPEC_PREFIX_ORIGIN
) &&
486 !get_literal_global()) {
487 struct strbuf sb
= STRBUF_INIT
;
489 /* Preserve the actual prefix length of each pattern */
490 prefix_magic(&sb
, prefixlen
, element_magic
);
492 strbuf_addstr(&sb
, match
);
493 item
->original
= strbuf_detach(&sb
, NULL
);
495 item
->original
= xstrdup(elt
);
498 if (magic
& PATHSPEC_LITERAL
) {
499 item
->nowildcard_len
= item
->len
;
501 item
->nowildcard_len
= simple_length(item
->match
);
502 if (item
->nowildcard_len
< prefixlen
)
503 item
->nowildcard_len
= prefixlen
;
507 if (magic
& PATHSPEC_GLOB
) {
509 * FIXME: should we enable ONESTAR in _GLOB for
510 * pattern "* * / * . c"?
513 if (item
->nowildcard_len
< item
->len
&&
514 item
->match
[item
->nowildcard_len
] == '*' &&
515 no_wildcard(item
->match
+ item
->nowildcard_len
+ 1))
516 item
->flags
|= PATHSPEC_ONESTAR
;
519 /* sanity checks, pathspec matchers assume these are sane */
520 if (item
->nowildcard_len
> item
->len
||
521 item
->prefix
> item
->len
) {
522 BUG("error initializing pathspec_item");
526 static int pathspec_item_cmp(const void *a_
, const void *b_
)
528 struct pathspec_item
*a
, *b
;
530 a
= (struct pathspec_item
*)a_
;
531 b
= (struct pathspec_item
*)b_
;
532 return strcmp(a
->match
, b
->match
);
535 void pathspec_magic_names(unsigned magic
, struct strbuf
*out
)
538 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
539 const struct pathspec_magic
*m
= pathspec_magic
+ i
;
540 if (!(magic
& m
->bit
))
543 strbuf_addstr(out
, ", ");
546 strbuf_addf(out
, _("'%s' (mnemonic: '%c')"),
547 m
->name
, m
->mnemonic
);
549 strbuf_addf(out
, "'%s'", m
->name
);
553 static void NORETURN
unsupported_magic(const char *pattern
,
556 struct strbuf sb
= STRBUF_INIT
;
557 pathspec_magic_names(magic
, &sb
);
559 * We may want to substitute "this command" with a command
560 * name. E.g. when "git add -p" or "git add -i" dies when running
563 die(_("%s: pathspec magic not supported by this command: %s"),
567 void parse_pathspec(struct pathspec
*pathspec
,
568 unsigned magic_mask
, unsigned flags
,
569 const char *prefix
, const char **argv
)
571 struct pathspec_item
*item
;
572 const char *entry
= argv
? *argv
: NULL
;
573 int i
, n
, prefixlen
, nr_exclude
= 0;
575 memset(pathspec
, 0, sizeof(*pathspec
));
577 if (flags
& PATHSPEC_MAXDEPTH_VALID
)
578 pathspec
->magic
|= PATHSPEC_MAXDEPTH
;
580 /* No arguments, no prefix -> no pathspec */
581 if (!entry
&& !prefix
)
584 if ((flags
& PATHSPEC_PREFER_CWD
) &&
585 (flags
& PATHSPEC_PREFER_FULL
))
586 BUG("PATHSPEC_PREFER_CWD and PATHSPEC_PREFER_FULL are incompatible");
588 /* No arguments with prefix -> prefix pathspec */
590 if (flags
& PATHSPEC_PREFER_FULL
)
593 if (!(flags
& PATHSPEC_PREFER_CWD
))
594 BUG("PATHSPEC_PREFER_CWD requires arguments");
596 pathspec
->items
= CALLOC_ARRAY(item
, 1);
597 item
->match
= xstrdup(prefix
);
598 item
->original
= xstrdup(prefix
);
599 item
->nowildcard_len
= item
->len
= strlen(prefix
);
600 item
->prefix
= item
->len
;
607 if (*argv
[n
] == '\0')
608 die("empty string is not a valid pathspec. "
609 "please use . instead if you meant to match all paths");
614 ALLOC_ARRAY(pathspec
->items
, n
+ 1);
615 item
= pathspec
->items
;
616 prefixlen
= prefix
? strlen(prefix
) : 0;
618 for (i
= 0; i
< n
; i
++) {
621 init_pathspec_item(item
+ i
, flags
, prefix
, prefixlen
, entry
);
623 if (item
[i
].magic
& PATHSPEC_EXCLUDE
)
625 if (item
[i
].magic
& magic_mask
)
626 unsupported_magic(entry
, item
[i
].magic
& magic_mask
);
628 if ((flags
& PATHSPEC_SYMLINK_LEADING_PATH
) &&
629 has_symlink_leading_path(item
[i
].match
, item
[i
].len
)) {
630 die(_("pathspec '%s' is beyond a symbolic link"), entry
);
633 if (item
[i
].nowildcard_len
< item
[i
].len
)
634 pathspec
->has_wildcard
= 1;
635 pathspec
->magic
|= item
[i
].magic
;
639 * If everything is an exclude pattern, add one positive pattern
640 * that matches everything. We allocated an extra one for this.
642 if (nr_exclude
== n
) {
643 int plen
= (!(flags
& PATHSPEC_PREFER_CWD
)) ? 0 : prefixlen
;
644 init_pathspec_item(item
+ n
, 0, prefix
, plen
, ".");
648 if (pathspec
->magic
& PATHSPEC_MAXDEPTH
) {
649 if (flags
& PATHSPEC_KEEP_ORDER
)
650 BUG("PATHSPEC_MAXDEPTH_VALID and PATHSPEC_KEEP_ORDER are incompatible");
651 QSORT(pathspec
->items
, pathspec
->nr
, pathspec_item_cmp
);
655 void parse_pathspec_file(struct pathspec
*pathspec
, unsigned magic_mask
,
656 unsigned flags
, const char *prefix
,
657 const char *file
, int nul_term_line
)
659 struct strvec parsed_file
= STRVEC_INIT
;
660 strbuf_getline_fn getline_fn
= nul_term_line
? strbuf_getline_nul
:
662 struct strbuf buf
= STRBUF_INIT
;
663 struct strbuf unquoted
= STRBUF_INIT
;
666 if (!strcmp(file
, "-"))
669 in
= xfopen(file
, "r");
671 while (getline_fn(&buf
, in
) != EOF
) {
672 if (!nul_term_line
&& buf
.buf
[0] == '"') {
673 strbuf_reset(&unquoted
);
674 if (unquote_c_style(&unquoted
, buf
.buf
, NULL
))
675 die(_("line is badly quoted: %s"), buf
.buf
);
676 strbuf_swap(&buf
, &unquoted
);
678 strvec_push(&parsed_file
, buf
.buf
);
682 strbuf_release(&unquoted
);
683 strbuf_release(&buf
);
687 parse_pathspec(pathspec
, magic_mask
, flags
, prefix
, parsed_file
.v
);
688 strvec_clear(&parsed_file
);
691 void copy_pathspec(struct pathspec
*dst
, const struct pathspec
*src
)
696 DUP_ARRAY(dst
->items
, src
->items
, dst
->nr
);
698 for (i
= 0; i
< dst
->nr
; i
++) {
699 struct pathspec_item
*d
= &dst
->items
[i
];
700 struct pathspec_item
*s
= &src
->items
[i
];
702 d
->match
= xstrdup(s
->match
);
703 d
->original
= xstrdup(s
->original
);
705 DUP_ARRAY(d
->attr_match
, s
->attr_match
, d
->attr_match_nr
);
706 for (j
= 0; j
< d
->attr_match_nr
; j
++) {
707 const char *value
= s
->attr_match
[j
].value
;
708 d
->attr_match
[j
].value
= xstrdup_or_null(value
);
711 d
->attr_check
= attr_check_dup(s
->attr_check
);
715 void clear_pathspec(struct pathspec
*pathspec
)
719 for (i
= 0; i
< pathspec
->nr
; i
++) {
720 free(pathspec
->items
[i
].match
);
721 free(pathspec
->items
[i
].original
);
723 for (j
= 0; j
< pathspec
->items
[i
].attr_match_nr
; j
++)
724 free(pathspec
->items
[i
].attr_match
[j
].value
);
725 free(pathspec
->items
[i
].attr_match
);
727 if (pathspec
->items
[i
].attr_check
)
728 attr_check_free(pathspec
->items
[i
].attr_check
);
731 FREE_AND_NULL(pathspec
->items
);
735 int match_pathspec_attrs(struct index_state
*istate
,
736 const char *name
, int namelen
,
737 const struct pathspec_item
*item
)
740 char *to_free
= NULL
;
743 name
= to_free
= xmemdupz(name
, namelen
);
745 git_check_attr(istate
, name
, item
->attr_check
);
749 for (i
= 0; i
< item
->attr_match_nr
; i
++) {
752 enum attr_match_mode match_mode
;
754 value
= item
->attr_check
->items
[i
].value
;
755 match_mode
= item
->attr_match
[i
].match_mode
;
757 if (ATTR_TRUE(value
))
758 matched
= (match_mode
== MATCH_SET
);
759 else if (ATTR_FALSE(value
))
760 matched
= (match_mode
== MATCH_UNSET
);
761 else if (ATTR_UNSET(value
))
762 matched
= (match_mode
== MATCH_UNSPECIFIED
);
764 matched
= (match_mode
== MATCH_VALUE
&&
765 !strcmp(item
->attr_match
[i
].value
, value
));
773 int pathspec_needs_expanded_index(struct index_state
*istate
,
774 const struct pathspec
*pathspec
)
778 char *skip_worktree_seen
= NULL
;
781 * If index is not sparse, no index expansion is needed.
783 if (!istate
->sparse_index
)
787 * When using a magic pathspec, assume for the sake of simplicity that
788 * the index needs to be expanded to match all matchable files.
793 for (i
= 0; i
< pathspec
->nr
; i
++) {
794 struct pathspec_item item
= pathspec
->items
[i
];
797 * If the pathspec item has a wildcard, the index should be expanded
798 * if the pathspec has the possibility of matching a subset of entries inside
799 * of a sparse directory (but not the entire directory).
801 * If the pathspec item is a literal path, the index only needs to be expanded
802 * if a) the pathspec isn't in the sparse checkout cone (to make sure we don't
803 * expand for in-cone files) and b) it doesn't match any sparse directories
804 * (since we can reset whole sparse directories without expanding them).
806 if (item
.nowildcard_len
< item
.len
) {
808 * Special case: if the pattern is a path inside the cone
809 * followed by only wildcards, the pattern cannot match
810 * partial sparse directories, so we know we don't need to
814 * - in-cone/foo***: doesn't need expanded index
815 * - not-in-cone/bar*: may need expanded index
816 * - **.c: may need expanded index
818 if (strspn(item
.original
+ item
.nowildcard_len
, "*") == item
.len
- item
.nowildcard_len
&&
819 path_in_cone_mode_sparse_checkout(item
.original
, istate
))
822 for (pos
= 0; pos
< istate
->cache_nr
; pos
++) {
823 struct cache_entry
*ce
= istate
->cache
[pos
];
825 if (!S_ISSPARSEDIR(ce
->ce_mode
))
829 * If the pre-wildcard length is longer than the sparse
830 * directory name and the sparse directory is the first
831 * component of the pathspec, need to expand the index.
833 if (item
.nowildcard_len
> ce_namelen(ce
) &&
834 !strncmp(item
.original
, ce
->name
, ce_namelen(ce
))) {
840 * If the pre-wildcard length is shorter than the sparse
841 * directory and the pathspec does not match the whole
842 * directory, need to expand the index.
844 if (!strncmp(item
.original
, ce
->name
, item
.nowildcard_len
) &&
845 wildmatch(item
.original
, ce
->name
, 0)) {
850 } else if (!path_in_cone_mode_sparse_checkout(item
.original
, istate
) &&
851 !matches_skip_worktree(pathspec
, i
, &skip_worktree_seen
))
858 free(skip_worktree_seen
);