diff --git a/builtin/add.c b/builtin/add.c
index e10a039070..9f0f6ebaff 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -170,7 +170,7 @@ static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec,
*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, 0);
return seen;
}
@@ -571,7 +571,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
int i;
if (!seen)
- seen = find_pathspecs_matching_against_index(&pathspec, &the_index);
+ seen = find_pathspecs_matching_against_index(&pathspec, &the_index, 0);
/*
* file_exists() assumes exact match
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 3c652748d5..235b7fc905 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -100,7 +100,7 @@ static int check_ignore(struct dir_struct *dir,
* 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, 0);
for (i = 0; i < pathspec.nr; i++) {
full_path = pathspec.items[i].match;
pattern = NULL;diff --git a/pathspec.c b/pathspec.c
index 7a229d8d22..e5e6b7458d 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -21,7 +21,7 @@
*/
void add_pathspec_matches_against_index(const struct pathspec *pathspec,
const struct index_state *istate,
- char *seen)
+ char *seen, int ignore_skip_worktree)
{
int num_unmatched = 0, i;
@@ -38,6 +38,8 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
return;
for (i = 0; i < istate->cache_nr; i++) {
const struct cache_entry *ce = istate->cache[i];
+ if (ignore_skip_worktree && ce_skip_worktree(ce))
+ continue;
ce_path_match(istate, ce, pathspec, seen);
}
}@@ -51,10 +53,12 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
* 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,
+ int ignore_skip_worktree)
{
char *seen = xcalloc(pathspec->nr, 1);
- add_pathspec_matches_against_index(pathspec, istate, seen);
+ add_pathspec_matches_against_index(pathspec, istate, seen,
+ ignore_skip_worktree);
return seen;
}
diff --git a/pathspec.h b/pathspec.h
index 454ce364fa..8202882ecd 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -151,9 +151,10 @@ static inline int ps_strcmp(const struct pathspec_item *item,
void add_pathspec_matches_against_index(const struct pathspec *pathspec,
const struct index_state *istate,
- char *seen);
+ char *seen, int ignore_skip_worktree);
char *find_pathspecs_matching_against_index(const struct pathspec *pathspec,
- const struct index_state *istate);
+ const struct index_state *istate,
+ int ignore_skip_worktree);
int match_pathspec_attrs(const struct index_state *istate,
const char *name, int namelen,
const struct pathspec_item *item);
--
2.29.2