diff options
author | Matheus Tavares <matheus.bernardino@usp.br> | 2021-04-08 22:41:27 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-04-08 23:18:03 +0200 |
commit | a20f70478ffcc66d30936920ebcc35ebfc12a7c7 (patch) | |
tree | 1e5865434bde7d8f5a94bb6f93ba304df307bd4c /pathspec.c | |
parent | refresh_index(): add flag to ignore SKIP_WORKTREE entries (diff) | |
download | git-a20f70478ffcc66d30936920ebcc35ebfc12a7c7.tar.xz git-a20f70478ffcc66d30936920ebcc35ebfc12a7c7.zip |
add: warn when asked to update SKIP_WORKTREE entries
`git add` already refrains from updating SKIP_WORKTREE entries, but it
silently exits with zero code when it is asked to do so. Instead, let's
warn the user and display a hint on how to update these entries.
Note that we only warn the user whey they give a pathspec item that
matches no eligible path for updating, but it does match one or more
SKIP_WORKTREE entries. A warning was chosen over erroring out right away
to reproduce the same behavior `add` already exhibits with ignored
files. This also allow users to continue their workflow without having
to invoke `add` again with only the eligible paths (as those will have
already been added).
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pathspec.c')
-rw-r--r-- | pathspec.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pathspec.c b/pathspec.c index 6d502e64e5..8247a65ec8 100644 --- a/pathspec.c +++ b/pathspec.c @@ -62,6 +62,21 @@ char *find_pathspecs_matching_against_index(const struct pathspec *pathspec, return seen; } +char *find_pathspecs_matching_skip_worktree(const struct pathspec *pathspec) +{ + struct index_state *istate = the_repository->index; + char *seen = xcalloc(pathspec->nr, 1); + int i; + + for (i = 0; i < istate->cache_nr; i++) { + struct cache_entry *ce = istate->cache[i]; + if (ce_skip_worktree(ce)) + ce_path_match(istate, ce, pathspec, seen); + } + + return seen; +} + /* * Magic pathspec * |