5 #include "environment.h"
9 #include "repository.h"
16 * Finds which of the given pathspecs match items in the index.
18 * For each pathspec, sets the corresponding entry in the seen[] array
19 * (which should be specs items long, i.e. the same size as pathspec)
20 * to the nature of the "closest" (i.e. most specific) match found for
21 * that pathspec in the index, if it was a closer type of match than
22 * the existing entry. As an optimization, matching is skipped
23 * altogether if seen[] already only contains non-zero entries.
25 * If seen[] has not already been written to, it may make sense
26 * to use find_pathspecs_matching_against_index() instead.
28 void add_pathspec_matches_against_index(const struct pathspec
*pathspec
,
29 struct index_state
*istate
,
31 enum ps_skip_worktree_action sw_action
)
33 int num_unmatched
= 0, i
;
36 * Since we are walking the index as if we were walking the directory,
37 * we have to mark the matched pathspec as seen; otherwise we will
38 * mistakenly think that the user gave a pathspec that did not match
41 for (i
= 0; i
< pathspec
->nr
; i
++)
46 for (i
= 0; i
< istate
->cache_nr
; i
++) {
47 const struct cache_entry
*ce
= istate
->cache
[i
];
48 if (sw_action
== PS_IGNORE_SKIP_WORKTREE
&&
49 (ce_skip_worktree(ce
) || !path_in_sparse_checkout(ce
->name
, istate
)))
51 ce_path_match(istate
, ce
, pathspec
, seen
);
56 * Finds which of the given pathspecs match items in the index.
58 * This is a one-shot wrapper around add_pathspec_matches_against_index()
59 * which allocates, populates, and returns a seen[] array indicating the
60 * nature of the "closest" (i.e. most specific) matches which each of the
61 * given pathspecs achieves against all items in the index.
63 char *find_pathspecs_matching_against_index(const struct pathspec
*pathspec
,
64 struct index_state
*istate
,
65 enum ps_skip_worktree_action sw_action
)
67 char *seen
= xcalloc(pathspec
->nr
, 1);
68 add_pathspec_matches_against_index(pathspec
, istate
, seen
, sw_action
);
72 char *find_pathspecs_matching_skip_worktree(const struct pathspec
*pathspec
)
74 struct index_state
*istate
= the_repository
->index
;
75 char *seen
= xcalloc(pathspec
->nr
, 1);
78 for (i
= 0; i
< istate
->cache_nr
; i
++) {
79 struct cache_entry
*ce
= istate
->cache
[i
];
80 if (ce_skip_worktree(ce
) || !path_in_sparse_checkout(ce
->name
, istate
))
81 ce_path_match(istate
, ce
, pathspec
, seen
);
90 * Possible future magic semantics include stuff like:
92 * { PATHSPEC_RECURSIVE, '*', "recursive" },
93 * { PATHSPEC_REGEXP, '\0', "regexp" },
97 static struct pathspec_magic
{
99 char mnemonic
; /* this cannot be ':'! */
101 } pathspec_magic
[] = {
102 { PATHSPEC_FROMTOP
, '/', "top" },
103 { PATHSPEC_LITERAL
, '\0', "literal" },
104 { PATHSPEC_GLOB
, '\0', "glob" },
105 { PATHSPEC_ICASE
, '\0', "icase" },
106 { PATHSPEC_EXCLUDE
, '!', "exclude" },
107 { PATHSPEC_ATTR
, '\0', "attr" },
110 static void prefix_magic(struct strbuf
*sb
, int prefixlen
, unsigned magic
)
113 strbuf_addstr(sb
, ":(");
114 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++)
115 if (magic
& pathspec_magic
[i
].bit
) {
116 if (sb
->buf
[sb
->len
- 1] != '(')
117 strbuf_addch(sb
, ',');
118 strbuf_addstr(sb
, pathspec_magic
[i
].name
);
120 strbuf_addf(sb
, ",prefix:%d)", prefixlen
);
123 static size_t strcspn_escaped(const char *s
, const char *stop
)
127 for (i
= s
; *i
; i
++) {
128 /* skip the escaped character */
129 if (i
[0] == '\\' && i
[1]) {
134 if (strchr(stop
, *i
))
140 static inline int invalid_value_char(const char ch
)
142 if (isalnum(ch
) || strchr(",-_", ch
))
147 static char *attr_value_unescape(const char *value
)
152 ret
= xmallocz(strlen(value
));
153 for (src
= value
, dst
= ret
; *src
; src
++, dst
++) {
156 die(_("Escape character '\\' not allowed as "
157 "last character in attr value"));
160 if (invalid_value_char(*src
))
161 die("cannot use '%c' for value matching", *src
);
168 static void parse_pathspec_attr_match(struct pathspec_item
*item
, const char *value
)
170 struct string_list_item
*si
;
171 struct string_list list
= STRING_LIST_INIT_DUP
;
173 if (item
->attr_check
|| item
->attr_match
)
174 die(_("Only one 'attr:' specification is allowed."));
176 if (!value
|| !*value
)
177 die(_("attr spec must not be empty"));
179 string_list_split(&list
, value
, ' ', -1);
180 string_list_remove_empty_items(&list
, 0);
182 item
->attr_check
= attr_check_alloc();
183 CALLOC_ARRAY(item
->attr_match
, list
.nr
);
185 for_each_string_list_item(si
, &list
) {
188 const struct git_attr
*a
;
190 int j
= item
->attr_match_nr
++;
191 const char *attr
= si
->string
;
192 struct attr_match
*am
= &item
->attr_match
[j
];
196 am
->match_mode
= MATCH_UNSPECIFIED
;
198 attr_len
= strlen(attr
);
201 am
->match_mode
= MATCH_UNSET
;
203 attr_len
= strlen(attr
);
206 attr_len
= strcspn(attr
, "=");
207 if (attr
[attr_len
] != '=')
208 am
->match_mode
= MATCH_SET
;
210 const char *v
= &attr
[attr_len
+ 1];
211 am
->match_mode
= MATCH_VALUE
;
212 am
->value
= attr_value_unescape(v
);
217 attr_name
= xmemdupz(attr
, attr_len
);
218 a
= git_attr(attr_name
);
220 die(_("invalid attribute name %s"), attr_name
);
222 attr_check_append(item
->attr_check
, a
);
227 if (item
->attr_check
->nr
!= item
->attr_match_nr
)
228 BUG("should have same number of entries");
230 string_list_clear(&list
, 0);
233 static inline int get_literal_global(void)
235 static int literal
= -1;
238 literal
= git_env_bool(GIT_LITERAL_PATHSPECS_ENVIRONMENT
, 0);
243 static inline int get_glob_global(void)
245 static int glob
= -1;
248 glob
= git_env_bool(GIT_GLOB_PATHSPECS_ENVIRONMENT
, 0);
253 static inline int get_noglob_global(void)
255 static int noglob
= -1;
258 noglob
= git_env_bool(GIT_NOGLOB_PATHSPECS_ENVIRONMENT
, 0);
263 static inline int get_icase_global(void)
265 static int icase
= -1;
268 icase
= git_env_bool(GIT_ICASE_PATHSPECS_ENVIRONMENT
, 0);
273 static int get_global_magic(int element_magic
)
275 int global_magic
= 0;
277 if (get_literal_global())
278 global_magic
|= PATHSPEC_LITERAL
;
280 /* --glob-pathspec is overridden by :(literal) */
281 if (get_glob_global() && !(element_magic
& PATHSPEC_LITERAL
))
282 global_magic
|= PATHSPEC_GLOB
;
284 if (get_glob_global() && get_noglob_global())
285 die(_("global 'glob' and 'noglob' pathspec settings are incompatible"));
287 if (get_icase_global())
288 global_magic
|= PATHSPEC_ICASE
;
290 if ((global_magic
& PATHSPEC_LITERAL
) &&
291 (global_magic
& ~PATHSPEC_LITERAL
))
292 die(_("global 'literal' pathspec setting is incompatible "
293 "with all other global pathspec settings"));
295 /* --noglob-pathspec adds :(literal) _unless_ :(glob) is specified */
296 if (get_noglob_global() && !(element_magic
& PATHSPEC_GLOB
))
297 global_magic
|= PATHSPEC_LITERAL
;
303 * Parse the pathspec element looking for long magic
305 * saves all magic in 'magic'
306 * if prefix magic is used, save the prefix length in 'prefix_len'
307 * returns the position in 'elem' after all magic has been parsed
309 static const char *parse_long_magic(unsigned *magic
, int *prefix_len
,
310 struct pathspec_item
*item
,
316 for (pos
= elem
+ 2; *pos
&& *pos
!= ')'; pos
= nextat
) {
317 size_t len
= strcspn_escaped(pos
, ",)");
321 nextat
= pos
+ len
+ 1; /* handle ',' */
323 nextat
= pos
+ len
; /* handle ')' and '\0' */
328 if (starts_with(pos
, "prefix:")) {
330 *prefix_len
= strtol(pos
+ 7, &endptr
, 10);
331 if (endptr
- pos
!= len
)
332 die(_("invalid parameter for pathspec magic 'prefix'"));
336 if (starts_with(pos
, "attr:")) {
337 char *attr_body
= xmemdupz(pos
+ 5, len
- 5);
338 parse_pathspec_attr_match(item
, attr_body
);
339 *magic
|= PATHSPEC_ATTR
;
344 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
345 if (strlen(pathspec_magic
[i
].name
) == len
&&
346 !strncmp(pathspec_magic
[i
].name
, pos
, len
)) {
347 *magic
|= pathspec_magic
[i
].bit
;
352 if (ARRAY_SIZE(pathspec_magic
) <= i
)
353 die(_("Invalid pathspec magic '%.*s' in '%s'"),
354 (int) len
, pos
, elem
);
358 die(_("Missing ')' at the end of pathspec magic in '%s'"),
366 * Parse the pathspec element looking for short magic
368 * saves all magic in 'magic'
369 * returns the position in 'elem' after all magic has been parsed
371 static const char *parse_short_magic(unsigned *magic
, const char *elem
)
375 for (pos
= elem
+ 1; *pos
&& *pos
!= ':'; pos
++) {
379 /* Special case alias for '!' */
381 *magic
|= PATHSPEC_EXCLUDE
;
385 if (!is_pathspec_magic(ch
))
388 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
389 if (pathspec_magic
[i
].mnemonic
== ch
) {
390 *magic
|= pathspec_magic
[i
].bit
;
395 if (ARRAY_SIZE(pathspec_magic
) <= i
)
396 die(_("Unimplemented pathspec magic '%c' in '%s'"),
406 static const char *parse_element_magic(unsigned *magic
, int *prefix_len
,
407 struct pathspec_item
*item
,
410 if (elem
[0] != ':' || get_literal_global())
411 return elem
; /* nothing to do */
412 else if (elem
[1] == '(')
414 return parse_long_magic(magic
, prefix_len
, item
, elem
);
417 return parse_short_magic(magic
, elem
);
421 * Perform the initialization of a pathspec_item based on a pathspec element.
423 static void init_pathspec_item(struct pathspec_item
*item
, unsigned flags
,
424 const char *prefix
, int prefixlen
,
427 unsigned magic
= 0, element_magic
= 0;
428 const char *copyfrom
= elt
;
430 int pathspec_prefix
= -1;
432 item
->attr_check
= NULL
;
433 item
->attr_match
= NULL
;
434 item
->attr_match_nr
= 0;
436 /* PATHSPEC_LITERAL_PATH ignores magic */
437 if (flags
& PATHSPEC_LITERAL_PATH
) {
438 magic
= PATHSPEC_LITERAL
;
440 copyfrom
= parse_element_magic(&element_magic
,
444 magic
|= element_magic
;
445 magic
|= get_global_magic(element_magic
);
450 if (pathspec_prefix
>= 0 &&
451 (prefixlen
|| (prefix
&& *prefix
)))
452 BUG("'prefix' magic is supposed to be used at worktree's root");
454 if ((magic
& PATHSPEC_LITERAL
) && (magic
& PATHSPEC_GLOB
))
455 die(_("%s: 'literal' and 'glob' are incompatible"), elt
);
457 /* Create match string which will be used for pathspec matching */
458 if (pathspec_prefix
>= 0) {
459 match
= xstrdup(copyfrom
);
460 prefixlen
= pathspec_prefix
;
461 } else if (magic
& PATHSPEC_FROMTOP
) {
462 match
= xstrdup(copyfrom
);
465 match
= prefix_path_gently(prefix
, prefixlen
,
466 &prefixlen
, copyfrom
);
468 const char *hint_path
= get_git_work_tree();
470 hint_path
= get_git_dir();
471 die(_("%s: '%s' is outside repository at '%s'"), elt
,
472 copyfrom
, absolute_path(hint_path
));
477 item
->len
= strlen(item
->match
);
478 item
->prefix
= prefixlen
;
481 * Prefix the pathspec (keep all magic) and assign to
482 * original. Useful for passing to another command.
484 if ((flags
& PATHSPEC_PREFIX_ORIGIN
) &&
485 !get_literal_global()) {
486 struct strbuf sb
= STRBUF_INIT
;
488 /* Preserve the actual prefix length of each pattern */
489 prefix_magic(&sb
, prefixlen
, element_magic
);
491 strbuf_addstr(&sb
, match
);
492 item
->original
= strbuf_detach(&sb
, NULL
);
494 item
->original
= xstrdup(elt
);
497 if (magic
& PATHSPEC_LITERAL
) {
498 item
->nowildcard_len
= item
->len
;
500 item
->nowildcard_len
= simple_length(item
->match
);
501 if (item
->nowildcard_len
< prefixlen
)
502 item
->nowildcard_len
= prefixlen
;
506 if (magic
& PATHSPEC_GLOB
) {
508 * FIXME: should we enable ONESTAR in _GLOB for
509 * pattern "* * / * . c"?
512 if (item
->nowildcard_len
< item
->len
&&
513 item
->match
[item
->nowildcard_len
] == '*' &&
514 no_wildcard(item
->match
+ item
->nowildcard_len
+ 1))
515 item
->flags
|= PATHSPEC_ONESTAR
;
518 /* sanity checks, pathspec matchers assume these are sane */
519 if (item
->nowildcard_len
> item
->len
||
520 item
->prefix
> item
->len
) {
521 BUG("error initializing pathspec_item");
525 static int pathspec_item_cmp(const void *a_
, const void *b_
)
527 struct pathspec_item
*a
, *b
;
529 a
= (struct pathspec_item
*)a_
;
530 b
= (struct pathspec_item
*)b_
;
531 return strcmp(a
->match
, b
->match
);
534 static void NORETURN
unsupported_magic(const char *pattern
,
537 struct strbuf sb
= STRBUF_INIT
;
539 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
540 const struct pathspec_magic
*m
= pathspec_magic
+ i
;
541 if (!(magic
& m
->bit
))
544 strbuf_addstr(&sb
, ", ");
547 strbuf_addf(&sb
, _("'%s' (mnemonic: '%c')"),
548 m
->name
, m
->mnemonic
);
550 strbuf_addf(&sb
, "'%s'", m
->name
);
553 * We may want to substitute "this command" with a command
554 * name. E.g. when "git add -p" or "git add -i" dies when running
557 die(_("%s: pathspec magic not supported by this command: %s"),
561 void parse_pathspec(struct pathspec
*pathspec
,
562 unsigned magic_mask
, unsigned flags
,
563 const char *prefix
, const char **argv
)
565 struct pathspec_item
*item
;
566 const char *entry
= argv
? *argv
: NULL
;
567 int i
, n
, prefixlen
, nr_exclude
= 0;
569 memset(pathspec
, 0, sizeof(*pathspec
));
571 if (flags
& PATHSPEC_MAXDEPTH_VALID
)
572 pathspec
->magic
|= PATHSPEC_MAXDEPTH
;
574 /* No arguments, no prefix -> no pathspec */
575 if (!entry
&& !prefix
)
578 if ((flags
& PATHSPEC_PREFER_CWD
) &&
579 (flags
& PATHSPEC_PREFER_FULL
))
580 BUG("PATHSPEC_PREFER_CWD and PATHSPEC_PREFER_FULL are incompatible");
582 /* No arguments with prefix -> prefix pathspec */
584 if (flags
& PATHSPEC_PREFER_FULL
)
587 if (!(flags
& PATHSPEC_PREFER_CWD
))
588 BUG("PATHSPEC_PREFER_CWD requires arguments");
590 pathspec
->items
= CALLOC_ARRAY(item
, 1);
591 item
->match
= xstrdup(prefix
);
592 item
->original
= xstrdup(prefix
);
593 item
->nowildcard_len
= item
->len
= strlen(prefix
);
594 item
->prefix
= item
->len
;
601 if (*argv
[n
] == '\0')
602 die("empty string is not a valid pathspec. "
603 "please use . instead if you meant to match all paths");
608 ALLOC_ARRAY(pathspec
->items
, n
+ 1);
609 item
= pathspec
->items
;
610 prefixlen
= prefix
? strlen(prefix
) : 0;
612 for (i
= 0; i
< n
; i
++) {
615 init_pathspec_item(item
+ i
, flags
, prefix
, prefixlen
, entry
);
617 if (item
[i
].magic
& PATHSPEC_EXCLUDE
)
619 if (item
[i
].magic
& magic_mask
)
620 unsupported_magic(entry
, item
[i
].magic
& magic_mask
);
622 if ((flags
& PATHSPEC_SYMLINK_LEADING_PATH
) &&
623 has_symlink_leading_path(item
[i
].match
, item
[i
].len
)) {
624 die(_("pathspec '%s' is beyond a symbolic link"), entry
);
627 if (item
[i
].nowildcard_len
< item
[i
].len
)
628 pathspec
->has_wildcard
= 1;
629 pathspec
->magic
|= item
[i
].magic
;
633 * If everything is an exclude pattern, add one positive pattern
634 * that matches everything. We allocated an extra one for this.
636 if (nr_exclude
== n
) {
637 int plen
= (!(flags
& PATHSPEC_PREFER_CWD
)) ? 0 : prefixlen
;
638 init_pathspec_item(item
+ n
, 0, prefix
, plen
, ".");
642 if (pathspec
->magic
& PATHSPEC_MAXDEPTH
) {
643 if (flags
& PATHSPEC_KEEP_ORDER
)
644 BUG("PATHSPEC_MAXDEPTH_VALID and PATHSPEC_KEEP_ORDER are incompatible");
645 QSORT(pathspec
->items
, pathspec
->nr
, pathspec_item_cmp
);
649 void parse_pathspec_file(struct pathspec
*pathspec
, unsigned magic_mask
,
650 unsigned flags
, const char *prefix
,
651 const char *file
, int nul_term_line
)
653 struct strvec parsed_file
= STRVEC_INIT
;
654 strbuf_getline_fn getline_fn
= nul_term_line
? strbuf_getline_nul
:
656 struct strbuf buf
= STRBUF_INIT
;
657 struct strbuf unquoted
= STRBUF_INIT
;
660 if (!strcmp(file
, "-"))
663 in
= xfopen(file
, "r");
665 while (getline_fn(&buf
, in
) != EOF
) {
666 if (!nul_term_line
&& buf
.buf
[0] == '"') {
667 strbuf_reset(&unquoted
);
668 if (unquote_c_style(&unquoted
, buf
.buf
, NULL
))
669 die(_("line is badly quoted: %s"), buf
.buf
);
670 strbuf_swap(&buf
, &unquoted
);
672 strvec_push(&parsed_file
, buf
.buf
);
676 strbuf_release(&unquoted
);
677 strbuf_release(&buf
);
681 parse_pathspec(pathspec
, magic_mask
, flags
, prefix
, parsed_file
.v
);
682 strvec_clear(&parsed_file
);
685 void copy_pathspec(struct pathspec
*dst
, const struct pathspec
*src
)
690 DUP_ARRAY(dst
->items
, src
->items
, dst
->nr
);
692 for (i
= 0; i
< dst
->nr
; i
++) {
693 struct pathspec_item
*d
= &dst
->items
[i
];
694 struct pathspec_item
*s
= &src
->items
[i
];
696 d
->match
= xstrdup(s
->match
);
697 d
->original
= xstrdup(s
->original
);
699 DUP_ARRAY(d
->attr_match
, s
->attr_match
, d
->attr_match_nr
);
700 for (j
= 0; j
< d
->attr_match_nr
; j
++) {
701 const char *value
= s
->attr_match
[j
].value
;
702 d
->attr_match
[j
].value
= xstrdup_or_null(value
);
705 d
->attr_check
= attr_check_dup(s
->attr_check
);
709 void clear_pathspec(struct pathspec
*pathspec
)
713 for (i
= 0; i
< pathspec
->nr
; i
++) {
714 free(pathspec
->items
[i
].match
);
715 free(pathspec
->items
[i
].original
);
717 for (j
= 0; j
< pathspec
->items
[i
].attr_match_nr
; j
++)
718 free(pathspec
->items
[i
].attr_match
[j
].value
);
719 free(pathspec
->items
[i
].attr_match
);
721 if (pathspec
->items
[i
].attr_check
)
722 attr_check_free(pathspec
->items
[i
].attr_check
);
725 FREE_AND_NULL(pathspec
->items
);
729 int match_pathspec_attrs(struct index_state
*istate
,
730 const char *name
, int namelen
,
731 const struct pathspec_item
*item
)
734 char *to_free
= NULL
;
737 name
= to_free
= xmemdupz(name
, namelen
);
739 git_check_attr(istate
, name
, item
->attr_check
);
743 for (i
= 0; i
< item
->attr_match_nr
; i
++) {
746 enum attr_match_mode match_mode
;
748 value
= item
->attr_check
->items
[i
].value
;
749 match_mode
= item
->attr_match
[i
].match_mode
;
751 if (ATTR_TRUE(value
))
752 matched
= (match_mode
== MATCH_SET
);
753 else if (ATTR_FALSE(value
))
754 matched
= (match_mode
== MATCH_UNSET
);
755 else if (ATTR_UNSET(value
))
756 matched
= (match_mode
== MATCH_UNSPECIFIED
);
758 matched
= (match_mode
== MATCH_VALUE
&&
759 !strcmp(item
->attr_match
[i
].value
, value
));
767 int pathspec_needs_expanded_index(struct index_state
*istate
,
768 const struct pathspec
*pathspec
)
772 char *skip_worktree_seen
= NULL
;
775 * If index is not sparse, no index expansion is needed.
777 if (!istate
->sparse_index
)
781 * When using a magic pathspec, assume for the sake of simplicity that
782 * the index needs to be expanded to match all matchable files.
787 for (i
= 0; i
< pathspec
->nr
; i
++) {
788 struct pathspec_item item
= pathspec
->items
[i
];
791 * If the pathspec item has a wildcard, the index should be expanded
792 * if the pathspec has the possibility of matching a subset of entries inside
793 * of a sparse directory (but not the entire directory).
795 * If the pathspec item is a literal path, the index only needs to be expanded
796 * if a) the pathspec isn't in the sparse checkout cone (to make sure we don't
797 * expand for in-cone files) and b) it doesn't match any sparse directories
798 * (since we can reset whole sparse directories without expanding them).
800 if (item
.nowildcard_len
< item
.len
) {
802 * Special case: if the pattern is a path inside the cone
803 * followed by only wildcards, the pattern cannot match
804 * partial sparse directories, so we know we don't need to
808 * - in-cone/foo***: doesn't need expanded index
809 * - not-in-cone/bar*: may need expanded index
810 * - **.c: may need expanded index
812 if (strspn(item
.original
+ item
.nowildcard_len
, "*") == item
.len
- item
.nowildcard_len
&&
813 path_in_cone_mode_sparse_checkout(item
.original
, istate
))
816 for (pos
= 0; pos
< istate
->cache_nr
; pos
++) {
817 struct cache_entry
*ce
= istate
->cache
[pos
];
819 if (!S_ISSPARSEDIR(ce
->ce_mode
))
823 * If the pre-wildcard length is longer than the sparse
824 * directory name and the sparse directory is the first
825 * component of the pathspec, need to expand the index.
827 if (item
.nowildcard_len
> ce_namelen(ce
) &&
828 !strncmp(item
.original
, ce
->name
, ce_namelen(ce
))) {
834 * If the pre-wildcard length is shorter than the sparse
835 * directory and the pathspec does not match the whole
836 * directory, need to expand the index.
838 if (!strncmp(item
.original
, ce
->name
, item
.nowildcard_len
) &&
839 wildmatch(item
.original
, ce
->name
, 0)) {
844 } else if (!path_in_cone_mode_sparse_checkout(item
.original
, istate
) &&
845 !matches_skip_worktree(pathspec
, i
, &skip_worktree_seen
))
852 free(skip_worktree_seen
);