summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorMatheus Tavares <matheus.bernardino@usp.br>2021-04-08 20:41:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-04-08 21:18:03 (GMT)
commit719630eb4826ff7f36bc060533dbccc3c96d151c (patch)
tree56bf2c8141c856f5e926fbddaf48ad9df8658a85 /builtin
parentd73dbafc2c25eb45090d6aa9d56fc21b40c78083 (diff)
downloadgit-719630eb4826ff7f36bc060533dbccc3c96d151c.zip
git-719630eb4826ff7f36bc060533dbccc3c96d151c.tar.gz
git-719630eb4826ff7f36bc060533dbccc3c96d151c.tar.bz2
pathspec: allow to ignore SKIP_WORKTREE entries on index matching
Add a new enum parameter to `add_pathspec_matches_against_index()` and `find_pathspecs_matching_against_index()`, allowing callers to specify whether these function should attempt to match SKIP_WORKTREE entries or not. This will be used in a future patch to make `git add` display a warning when it is asked to update SKIP_WORKTREE entries. Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/add.c6
-rw-r--r--builtin/check-ignore.c3
2 files changed, 6 insertions, 3 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 5fec21a..050cb8a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -177,7 +177,8 @@ 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,
+ PS_HEED_SKIP_WORKTREE);
return seen;
}
@@ -578,7 +579,8 @@ 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, PS_HEED_SKIP_WORKTREE);
/*
* file_exists() assumes exact match
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 3c65274..0f4480a 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -100,7 +100,8 @@ 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,
+ PS_HEED_SKIP_WORKTREE);
for (i = 0; i < pathspec.nr; i++) {
full_path = pathspec.items[i].match;
pattern = NULL;