*dst++ = entry;
}
dir->nr = dst - dir->entries;
- add_pathspec_matches_against_index(pathspec, &the_index, seen);
+ add_pathspec_matches_against_index(pathspec, &the_index, seen,
+ PS_HEED_SKIP_WORKTREE);
return seen;
}
int i;
if (!seen)
- seen = find_pathspecs_matching_against_index(&pathspec, &the_index);
+ seen = find_pathspecs_matching_against_index(&pathspec,
+ &the_index, PS_HEED_SKIP_WORKTREE);
/*
* file_exists() assumes exact match
* should not be ignored, in order to be consistent with
* 'git status', 'git add' etc.
*/
- seen = find_pathspecs_matching_against_index(&pathspec, &the_index);
+ seen = find_pathspecs_matching_against_index(&pathspec, &the_index,
+ PS_HEED_SKIP_WORKTREE);
for (i = 0; i < pathspec.nr; i++) {
full_path = pathspec.items[i].match;
pattern = NULL;
*/
void add_pathspec_matches_against_index(const struct pathspec *pathspec,
const struct index_state *istate,
- char *seen)
+ char *seen,
+ enum ps_skip_worktree_action sw_action)
{
int num_unmatched = 0, i;
return;
for (i = 0; i < istate->cache_nr; i++) {
const struct cache_entry *ce = istate->cache[i];
+ if (sw_action == PS_IGNORE_SKIP_WORKTREE && ce_skip_worktree(ce))
+ continue;
ce_path_match(istate, ce, pathspec, seen);
}
}
* given pathspecs achieves against all items in the index.
*/
char *find_pathspecs_matching_against_index(const struct pathspec *pathspec,
- const struct index_state *istate)
+ const struct index_state *istate,
+ enum ps_skip_worktree_action sw_action)
{
char *seen = xcalloc(pathspec->nr, 1);
- add_pathspec_matches_against_index(pathspec, istate, seen);
+ add_pathspec_matches_against_index(pathspec, istate, seen, sw_action);
return seen;
}
return strcmp(s1, s2);
}
+enum ps_skip_worktree_action {
+ PS_HEED_SKIP_WORKTREE = 0,
+ PS_IGNORE_SKIP_WORKTREE = 1
+};
void add_pathspec_matches_against_index(const struct pathspec *pathspec,
const struct index_state *istate,
- char *seen);
+ char *seen,
+ enum ps_skip_worktree_action sw_action);
char *find_pathspecs_matching_against_index(const struct pathspec *pathspec,
- const struct index_state *istate);
+ const struct index_state *istate,
+ enum ps_skip_worktree_action sw_action);
int match_pathspec_attrs(const struct index_state *istate,
const char *name, int namelen,
const struct pathspec_item *item);