5 #include "environment.h"
14 * Finds which of the given pathspecs match items in the index.
16 * For each pathspec, sets the corresponding entry in the seen[] array
17 * (which should be specs items long, i.e. the same size as pathspec)
18 * to the nature of the "closest" (i.e. most specific) match found for
19 * that pathspec in the index, if it was a closer type of match than
20 * the existing entry. As an optimization, matching is skipped
21 * altogether if seen[] already only contains non-zero entries.
23 * If seen[] has not already been written to, it may make sense
24 * to use find_pathspecs_matching_against_index() instead.
26 void add_pathspec_matches_against_index(const struct pathspec
*pathspec
,
27 struct index_state
*istate
,
29 enum ps_skip_worktree_action sw_action
)
31 int num_unmatched
= 0, i
;
34 * Since we are walking the index as if we were walking the directory,
35 * we have to mark the matched pathspec as seen; otherwise we will
36 * mistakenly think that the user gave a pathspec that did not match
39 for (i
= 0; i
< pathspec
->nr
; i
++)
44 for (i
= 0; i
< istate
->cache_nr
; i
++) {
45 const struct cache_entry
*ce
= istate
->cache
[i
];
46 if (sw_action
== PS_IGNORE_SKIP_WORKTREE
&&
47 (ce_skip_worktree(ce
) || !path_in_sparse_checkout(ce
->name
, istate
)))
49 ce_path_match(istate
, ce
, pathspec
, seen
);
54 * Finds which of the given pathspecs match items in the index.
56 * This is a one-shot wrapper around add_pathspec_matches_against_index()
57 * which allocates, populates, and returns a seen[] array indicating the
58 * nature of the "closest" (i.e. most specific) matches which each of the
59 * given pathspecs achieves against all items in the index.
61 char *find_pathspecs_matching_against_index(const struct pathspec
*pathspec
,
62 struct index_state
*istate
,
63 enum ps_skip_worktree_action sw_action
)
65 char *seen
= xcalloc(pathspec
->nr
, 1);
66 add_pathspec_matches_against_index(pathspec
, istate
, seen
, sw_action
);
70 char *find_pathspecs_matching_skip_worktree(const struct pathspec
*pathspec
)
72 struct index_state
*istate
= the_repository
->index
;
73 char *seen
= xcalloc(pathspec
->nr
, 1);
76 for (i
= 0; i
< istate
->cache_nr
; i
++) {
77 struct cache_entry
*ce
= istate
->cache
[i
];
78 if (ce_skip_worktree(ce
) || !path_in_sparse_checkout(ce
->name
, istate
))
79 ce_path_match(istate
, ce
, pathspec
, seen
);
88 * Possible future magic semantics include stuff like:
90 * { PATHSPEC_RECURSIVE, '*', "recursive" },
91 * { PATHSPEC_REGEXP, '\0', "regexp" },
95 static struct pathspec_magic
{
97 char mnemonic
; /* this cannot be ':'! */
99 } pathspec_magic
[] = {
100 { PATHSPEC_FROMTOP
, '/', "top" },
101 { PATHSPEC_LITERAL
, '\0', "literal" },
102 { PATHSPEC_GLOB
, '\0', "glob" },
103 { PATHSPEC_ICASE
, '\0', "icase" },
104 { PATHSPEC_EXCLUDE
, '!', "exclude" },
105 { PATHSPEC_ATTR
, '\0', "attr" },
108 static void prefix_magic(struct strbuf
*sb
, int prefixlen
, unsigned magic
)
111 strbuf_addstr(sb
, ":(");
112 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++)
113 if (magic
& pathspec_magic
[i
].bit
) {
114 if (sb
->buf
[sb
->len
- 1] != '(')
115 strbuf_addch(sb
, ',');
116 strbuf_addstr(sb
, pathspec_magic
[i
].name
);
118 strbuf_addf(sb
, ",prefix:%d)", prefixlen
);
121 static size_t strcspn_escaped(const char *s
, const char *stop
)
125 for (i
= s
; *i
; i
++) {
126 /* skip the escaped character */
127 if (i
[0] == '\\' && i
[1]) {
132 if (strchr(stop
, *i
))
138 static inline int invalid_value_char(const char ch
)
140 if (isalnum(ch
) || strchr(",-_", ch
))
145 static char *attr_value_unescape(const char *value
)
150 ret
= xmallocz(strlen(value
));
151 for (src
= value
, dst
= ret
; *src
; src
++, dst
++) {
154 die(_("Escape character '\\' not allowed as "
155 "last character in attr value"));
158 if (invalid_value_char(*src
))
159 die("cannot use '%c' for value matching", *src
);
166 static void parse_pathspec_attr_match(struct pathspec_item
*item
, const char *value
)
168 struct string_list_item
*si
;
169 struct string_list list
= STRING_LIST_INIT_DUP
;
171 if (item
->attr_check
|| item
->attr_match
)
172 die(_("Only one 'attr:' specification is allowed."));
174 if (!value
|| !*value
)
175 die(_("attr spec must not be empty"));
177 string_list_split(&list
, value
, ' ', -1);
178 string_list_remove_empty_items(&list
, 0);
180 item
->attr_check
= attr_check_alloc();
181 CALLOC_ARRAY(item
->attr_match
, list
.nr
);
183 for_each_string_list_item(si
, &list
) {
186 const struct git_attr
*a
;
188 int j
= item
->attr_match_nr
++;
189 const char *attr
= si
->string
;
190 struct attr_match
*am
= &item
->attr_match
[j
];
194 am
->match_mode
= MATCH_UNSPECIFIED
;
196 attr_len
= strlen(attr
);
199 am
->match_mode
= MATCH_UNSET
;
201 attr_len
= strlen(attr
);
204 attr_len
= strcspn(attr
, "=");
205 if (attr
[attr_len
] != '=')
206 am
->match_mode
= MATCH_SET
;
208 const char *v
= &attr
[attr_len
+ 1];
209 am
->match_mode
= MATCH_VALUE
;
210 am
->value
= attr_value_unescape(v
);
215 attr_name
= xmemdupz(attr
, attr_len
);
216 a
= git_attr(attr_name
);
218 die(_("invalid attribute name %s"), attr_name
);
220 attr_check_append(item
->attr_check
, a
);
225 if (item
->attr_check
->nr
!= item
->attr_match_nr
)
226 BUG("should have same number of entries");
228 string_list_clear(&list
, 0);
231 static inline int get_literal_global(void)
233 static int literal
= -1;
236 literal
= git_env_bool(GIT_LITERAL_PATHSPECS_ENVIRONMENT
, 0);
241 static inline int get_glob_global(void)
243 static int glob
= -1;
246 glob
= git_env_bool(GIT_GLOB_PATHSPECS_ENVIRONMENT
, 0);
251 static inline int get_noglob_global(void)
253 static int noglob
= -1;
256 noglob
= git_env_bool(GIT_NOGLOB_PATHSPECS_ENVIRONMENT
, 0);
261 static inline int get_icase_global(void)
263 static int icase
= -1;
266 icase
= git_env_bool(GIT_ICASE_PATHSPECS_ENVIRONMENT
, 0);
271 static int get_global_magic(int element_magic
)
273 int global_magic
= 0;
275 if (get_literal_global())
276 global_magic
|= PATHSPEC_LITERAL
;
278 /* --glob-pathspec is overridden by :(literal) */
279 if (get_glob_global() && !(element_magic
& PATHSPEC_LITERAL
))
280 global_magic
|= PATHSPEC_GLOB
;
282 if (get_glob_global() && get_noglob_global())
283 die(_("global 'glob' and 'noglob' pathspec settings are incompatible"));
285 if (get_icase_global())
286 global_magic
|= PATHSPEC_ICASE
;
288 if ((global_magic
& PATHSPEC_LITERAL
) &&
289 (global_magic
& ~PATHSPEC_LITERAL
))
290 die(_("global 'literal' pathspec setting is incompatible "
291 "with all other global pathspec settings"));
293 /* --noglob-pathspec adds :(literal) _unless_ :(glob) is specified */
294 if (get_noglob_global() && !(element_magic
& PATHSPEC_GLOB
))
295 global_magic
|= PATHSPEC_LITERAL
;
301 * Parse the pathspec element looking for long magic
303 * saves all magic in 'magic'
304 * if prefix magic is used, save the prefix length in 'prefix_len'
305 * returns the position in 'elem' after all magic has been parsed
307 static const char *parse_long_magic(unsigned *magic
, int *prefix_len
,
308 struct pathspec_item
*item
,
314 for (pos
= elem
+ 2; *pos
&& *pos
!= ')'; pos
= nextat
) {
315 size_t len
= strcspn_escaped(pos
, ",)");
319 nextat
= pos
+ len
+ 1; /* handle ',' */
321 nextat
= pos
+ len
; /* handle ')' and '\0' */
326 if (starts_with(pos
, "prefix:")) {
328 *prefix_len
= strtol(pos
+ 7, &endptr
, 10);
329 if (endptr
- pos
!= len
)
330 die(_("invalid parameter for pathspec magic 'prefix'"));
334 if (starts_with(pos
, "attr:")) {
335 char *attr_body
= xmemdupz(pos
+ 5, len
- 5);
336 parse_pathspec_attr_match(item
, attr_body
);
337 *magic
|= PATHSPEC_ATTR
;
342 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
343 if (strlen(pathspec_magic
[i
].name
) == len
&&
344 !strncmp(pathspec_magic
[i
].name
, pos
, len
)) {
345 *magic
|= pathspec_magic
[i
].bit
;
350 if (ARRAY_SIZE(pathspec_magic
) <= i
)
351 die(_("Invalid pathspec magic '%.*s' in '%s'"),
352 (int) len
, pos
, elem
);
356 die(_("Missing ')' at the end of pathspec magic in '%s'"),
364 * Parse the pathspec element looking for short magic
366 * saves all magic in 'magic'
367 * returns the position in 'elem' after all magic has been parsed
369 static const char *parse_short_magic(unsigned *magic
, const char *elem
)
373 for (pos
= elem
+ 1; *pos
&& *pos
!= ':'; pos
++) {
377 /* Special case alias for '!' */
379 *magic
|= PATHSPEC_EXCLUDE
;
383 if (!is_pathspec_magic(ch
))
386 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
387 if (pathspec_magic
[i
].mnemonic
== ch
) {
388 *magic
|= pathspec_magic
[i
].bit
;
393 if (ARRAY_SIZE(pathspec_magic
) <= i
)
394 die(_("Unimplemented pathspec magic '%c' in '%s'"),
404 static const char *parse_element_magic(unsigned *magic
, int *prefix_len
,
405 struct pathspec_item
*item
,
408 if (elem
[0] != ':' || get_literal_global())
409 return elem
; /* nothing to do */
410 else if (elem
[1] == '(')
412 return parse_long_magic(magic
, prefix_len
, item
, elem
);
415 return parse_short_magic(magic
, elem
);
419 * Perform the initialization of a pathspec_item based on a pathspec element.
421 static void init_pathspec_item(struct pathspec_item
*item
, unsigned flags
,
422 const char *prefix
, int prefixlen
,
425 unsigned magic
= 0, element_magic
= 0;
426 const char *copyfrom
= elt
;
428 int pathspec_prefix
= -1;
430 item
->attr_check
= NULL
;
431 item
->attr_match
= NULL
;
432 item
->attr_match_nr
= 0;
434 /* PATHSPEC_LITERAL_PATH ignores magic */
435 if (flags
& PATHSPEC_LITERAL_PATH
) {
436 magic
= PATHSPEC_LITERAL
;
438 copyfrom
= parse_element_magic(&element_magic
,
442 magic
|= element_magic
;
443 magic
|= get_global_magic(element_magic
);
448 if (pathspec_prefix
>= 0 &&
449 (prefixlen
|| (prefix
&& *prefix
)))
450 BUG("'prefix' magic is supposed to be used at worktree's root");
452 if ((magic
& PATHSPEC_LITERAL
) && (magic
& PATHSPEC_GLOB
))
453 die(_("%s: 'literal' and 'glob' are incompatible"), elt
);
455 /* Create match string which will be used for pathspec matching */
456 if (pathspec_prefix
>= 0) {
457 match
= xstrdup(copyfrom
);
458 prefixlen
= pathspec_prefix
;
459 } else if (magic
& PATHSPEC_FROMTOP
) {
460 match
= xstrdup(copyfrom
);
463 match
= prefix_path_gently(prefix
, prefixlen
,
464 &prefixlen
, copyfrom
);
466 const char *hint_path
= get_git_work_tree();
468 hint_path
= get_git_dir();
469 die(_("%s: '%s' is outside repository at '%s'"), elt
,
470 copyfrom
, absolute_path(hint_path
));
475 item
->len
= strlen(item
->match
);
476 item
->prefix
= prefixlen
;
479 * Prefix the pathspec (keep all magic) and assign to
480 * original. Useful for passing to another command.
482 if ((flags
& PATHSPEC_PREFIX_ORIGIN
) &&
483 !get_literal_global()) {
484 struct strbuf sb
= STRBUF_INIT
;
486 /* Preserve the actual prefix length of each pattern */
487 prefix_magic(&sb
, prefixlen
, element_magic
);
489 strbuf_addstr(&sb
, match
);
490 item
->original
= strbuf_detach(&sb
, NULL
);
492 item
->original
= xstrdup(elt
);
495 if (magic
& PATHSPEC_LITERAL
) {
496 item
->nowildcard_len
= item
->len
;
498 item
->nowildcard_len
= simple_length(item
->match
);
499 if (item
->nowildcard_len
< prefixlen
)
500 item
->nowildcard_len
= prefixlen
;
504 if (magic
& PATHSPEC_GLOB
) {
506 * FIXME: should we enable ONESTAR in _GLOB for
507 * pattern "* * / * . c"?
510 if (item
->nowildcard_len
< item
->len
&&
511 item
->match
[item
->nowildcard_len
] == '*' &&
512 no_wildcard(item
->match
+ item
->nowildcard_len
+ 1))
513 item
->flags
|= PATHSPEC_ONESTAR
;
516 /* sanity checks, pathspec matchers assume these are sane */
517 if (item
->nowildcard_len
> item
->len
||
518 item
->prefix
> item
->len
) {
519 BUG("error initializing pathspec_item");
523 static int pathspec_item_cmp(const void *a_
, const void *b_
)
525 struct pathspec_item
*a
, *b
;
527 a
= (struct pathspec_item
*)a_
;
528 b
= (struct pathspec_item
*)b_
;
529 return strcmp(a
->match
, b
->match
);
532 static void NORETURN
unsupported_magic(const char *pattern
,
535 struct strbuf sb
= STRBUF_INIT
;
537 for (i
= 0; i
< ARRAY_SIZE(pathspec_magic
); i
++) {
538 const struct pathspec_magic
*m
= pathspec_magic
+ i
;
539 if (!(magic
& m
->bit
))
542 strbuf_addstr(&sb
, ", ");
545 strbuf_addf(&sb
, _("'%s' (mnemonic: '%c')"),
546 m
->name
, m
->mnemonic
);
548 strbuf_addf(&sb
, "'%s'", m
->name
);
551 * We may want to substitute "this command" with a command
552 * name. E.g. when "git add -p" or "git add -i" dies when running
555 die(_("%s: pathspec magic not supported by this command: %s"),
559 void parse_pathspec(struct pathspec
*pathspec
,
560 unsigned magic_mask
, unsigned flags
,
561 const char *prefix
, const char **argv
)
563 struct pathspec_item
*item
;
564 const char *entry
= argv
? *argv
: NULL
;
565 int i
, n
, prefixlen
, nr_exclude
= 0;
567 memset(pathspec
, 0, sizeof(*pathspec
));
569 if (flags
& PATHSPEC_MAXDEPTH_VALID
)
570 pathspec
->magic
|= PATHSPEC_MAXDEPTH
;
572 /* No arguments, no prefix -> no pathspec */
573 if (!entry
&& !prefix
)
576 if ((flags
& PATHSPEC_PREFER_CWD
) &&
577 (flags
& PATHSPEC_PREFER_FULL
))
578 BUG("PATHSPEC_PREFER_CWD and PATHSPEC_PREFER_FULL are incompatible");
580 /* No arguments with prefix -> prefix pathspec */
582 if (flags
& PATHSPEC_PREFER_FULL
)
585 if (!(flags
& PATHSPEC_PREFER_CWD
))
586 BUG("PATHSPEC_PREFER_CWD requires arguments");
588 pathspec
->items
= CALLOC_ARRAY(item
, 1);
589 item
->match
= xstrdup(prefix
);
590 item
->original
= xstrdup(prefix
);
591 item
->nowildcard_len
= item
->len
= strlen(prefix
);
592 item
->prefix
= item
->len
;
599 if (*argv
[n
] == '\0')
600 die("empty string is not a valid pathspec. "
601 "please use . instead if you meant to match all paths");
606 ALLOC_ARRAY(pathspec
->items
, n
+ 1);
607 item
= pathspec
->items
;
608 prefixlen
= prefix
? strlen(prefix
) : 0;
610 for (i
= 0; i
< n
; i
++) {
613 init_pathspec_item(item
+ i
, flags
, prefix
, prefixlen
, entry
);
615 if (item
[i
].magic
& PATHSPEC_EXCLUDE
)
617 if (item
[i
].magic
& magic_mask
)
618 unsupported_magic(entry
, item
[i
].magic
& magic_mask
);
620 if ((flags
& PATHSPEC_SYMLINK_LEADING_PATH
) &&
621 has_symlink_leading_path(item
[i
].match
, item
[i
].len
)) {
622 die(_("pathspec '%s' is beyond a symbolic link"), entry
);
625 if (item
[i
].nowildcard_len
< item
[i
].len
)
626 pathspec
->has_wildcard
= 1;
627 pathspec
->magic
|= item
[i
].magic
;
631 * If everything is an exclude pattern, add one positive pattern
632 * that matches everything. We allocated an extra one for this.
634 if (nr_exclude
== n
) {
635 int plen
= (!(flags
& PATHSPEC_PREFER_CWD
)) ? 0 : prefixlen
;
636 init_pathspec_item(item
+ n
, 0, prefix
, plen
, ".");
640 if (pathspec
->magic
& PATHSPEC_MAXDEPTH
) {
641 if (flags
& PATHSPEC_KEEP_ORDER
)
642 BUG("PATHSPEC_MAXDEPTH_VALID and PATHSPEC_KEEP_ORDER are incompatible");
643 QSORT(pathspec
->items
, pathspec
->nr
, pathspec_item_cmp
);
647 void parse_pathspec_file(struct pathspec
*pathspec
, unsigned magic_mask
,
648 unsigned flags
, const char *prefix
,
649 const char *file
, int nul_term_line
)
651 struct strvec parsed_file
= STRVEC_INIT
;
652 strbuf_getline_fn getline_fn
= nul_term_line
? strbuf_getline_nul
:
654 struct strbuf buf
= STRBUF_INIT
;
655 struct strbuf unquoted
= STRBUF_INIT
;
658 if (!strcmp(file
, "-"))
661 in
= xfopen(file
, "r");
663 while (getline_fn(&buf
, in
) != EOF
) {
664 if (!nul_term_line
&& buf
.buf
[0] == '"') {
665 strbuf_reset(&unquoted
);
666 if (unquote_c_style(&unquoted
, buf
.buf
, NULL
))
667 die(_("line is badly quoted: %s"), buf
.buf
);
668 strbuf_swap(&buf
, &unquoted
);
670 strvec_push(&parsed_file
, buf
.buf
);
674 strbuf_release(&unquoted
);
675 strbuf_release(&buf
);
679 parse_pathspec(pathspec
, magic_mask
, flags
, prefix
, parsed_file
.v
);
680 strvec_clear(&parsed_file
);
683 void copy_pathspec(struct pathspec
*dst
, const struct pathspec
*src
)
688 DUP_ARRAY(dst
->items
, src
->items
, dst
->nr
);
690 for (i
= 0; i
< dst
->nr
; i
++) {
691 struct pathspec_item
*d
= &dst
->items
[i
];
692 struct pathspec_item
*s
= &src
->items
[i
];
694 d
->match
= xstrdup(s
->match
);
695 d
->original
= xstrdup(s
->original
);
697 DUP_ARRAY(d
->attr_match
, s
->attr_match
, d
->attr_match_nr
);
698 for (j
= 0; j
< d
->attr_match_nr
; j
++) {
699 const char *value
= s
->attr_match
[j
].value
;
700 d
->attr_match
[j
].value
= xstrdup_or_null(value
);
703 d
->attr_check
= attr_check_dup(s
->attr_check
);
707 void clear_pathspec(struct pathspec
*pathspec
)
711 for (i
= 0; i
< pathspec
->nr
; i
++) {
712 free(pathspec
->items
[i
].match
);
713 free(pathspec
->items
[i
].original
);
715 for (j
= 0; j
< pathspec
->items
[i
].attr_match_nr
; j
++)
716 free(pathspec
->items
[i
].attr_match
[j
].value
);
717 free(pathspec
->items
[i
].attr_match
);
719 if (pathspec
->items
[i
].attr_check
)
720 attr_check_free(pathspec
->items
[i
].attr_check
);
723 FREE_AND_NULL(pathspec
->items
);
727 int match_pathspec_attrs(struct index_state
*istate
,
728 const char *name
, int namelen
,
729 const struct pathspec_item
*item
)
732 char *to_free
= NULL
;
735 name
= to_free
= xmemdupz(name
, namelen
);
737 git_check_attr(istate
, NULL
, name
, item
->attr_check
);
741 for (i
= 0; i
< item
->attr_match_nr
; i
++) {
744 enum attr_match_mode match_mode
;
746 value
= item
->attr_check
->items
[i
].value
;
747 match_mode
= item
->attr_match
[i
].match_mode
;
749 if (ATTR_TRUE(value
))
750 matched
= (match_mode
== MATCH_SET
);
751 else if (ATTR_FALSE(value
))
752 matched
= (match_mode
== MATCH_UNSET
);
753 else if (ATTR_UNSET(value
))
754 matched
= (match_mode
== MATCH_UNSPECIFIED
);
756 matched
= (match_mode
== MATCH_VALUE
&&
757 !strcmp(item
->attr_match
[i
].value
, value
));
765 int pathspec_needs_expanded_index(struct index_state
*istate
,
766 const struct pathspec
*pathspec
)
770 char *skip_worktree_seen
= NULL
;
773 * If index is not sparse, no index expansion is needed.
775 if (!istate
->sparse_index
)
779 * When using a magic pathspec, assume for the sake of simplicity that
780 * the index needs to be expanded to match all matchable files.
785 for (i
= 0; i
< pathspec
->nr
; i
++) {
786 struct pathspec_item item
= pathspec
->items
[i
];
789 * If the pathspec item has a wildcard, the index should be expanded
790 * if the pathspec has the possibility of matching a subset of entries inside
791 * of a sparse directory (but not the entire directory).
793 * If the pathspec item is a literal path, the index only needs to be expanded
794 * if a) the pathspec isn't in the sparse checkout cone (to make sure we don't
795 * expand for in-cone files) and b) it doesn't match any sparse directories
796 * (since we can reset whole sparse directories without expanding them).
798 if (item
.nowildcard_len
< item
.len
) {
800 * Special case: if the pattern is a path inside the cone
801 * followed by only wildcards, the pattern cannot match
802 * partial sparse directories, so we know we don't need to
806 * - in-cone/foo***: doesn't need expanded index
807 * - not-in-cone/bar*: may need expanded index
808 * - **.c: may need expanded index
810 if (strspn(item
.original
+ item
.nowildcard_len
, "*") == item
.len
- item
.nowildcard_len
&&
811 path_in_cone_mode_sparse_checkout(item
.original
, istate
))
814 for (pos
= 0; pos
< istate
->cache_nr
; pos
++) {
815 struct cache_entry
*ce
= istate
->cache
[pos
];
817 if (!S_ISSPARSEDIR(ce
->ce_mode
))
821 * If the pre-wildcard length is longer than the sparse
822 * directory name and the sparse directory is the first
823 * component of the pathspec, need to expand the index.
825 if (item
.nowildcard_len
> ce_namelen(ce
) &&
826 !strncmp(item
.original
, ce
->name
, ce_namelen(ce
))) {
832 * If the pre-wildcard length is shorter than the sparse
833 * directory and the pathspec does not match the whole
834 * directory, need to expand the index.
836 if (!strncmp(item
.original
, ce
->name
, item
.nowildcard_len
) &&
837 wildmatch(item
.original
, ce
->name
, 0)) {
842 } else if (!path_in_cone_mode_sparse_checkout(item
.original
, istate
) &&
843 !matches_skip_worktree(pathspec
, i
, &skip_worktree_seen
))
850 free(skip_worktree_seen
);