Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-05-07 06:47:39 +0300
committerJunio C Hamano <gitster@pobox.com>2021-05-07 06:47:40 +0300
commitfe069dce6251f40eb3d54861500c92afb0e481d9 (patch)
treea414af6ca4ba1fd452249ee59a85157a49bfa119 /pathspec.c
parente706aaf3bc8ad97877cbf21887f96c5af66c7562 (diff)
parentd5f4b8260f623d6fdef36d5eaa8a0c2350390472 (diff)
Merge branch 'mt/add-rm-in-sparse-checkout'
"git add" and "git rm" learned not to touch those paths that are outside of sparse checkout. * mt/add-rm-in-sparse-checkout: rm: honor sparse checkout patterns add: warn when asked to update SKIP_WORKTREE entries refresh_index(): add flag to ignore SKIP_WORKTREE entries pathspec: allow to ignore SKIP_WORKTREE entries on index matching add: make --chmod and --renormalize honor sparse checkouts t3705: add tests for `git add` in sparse checkouts add: include magic part of pathspec on --refresh error
Diffstat (limited to 'pathspec.c')
-rw-r--r--pathspec.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/pathspec.c b/pathspec.c
index 14c7e9fbe3..08f8d3eedc 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -21,7 +21,8 @@
*/
void add_pathspec_matches_against_index(const struct pathspec *pathspec,
struct index_state *istate,
- char *seen)
+ char *seen,
+ enum ps_skip_worktree_action sw_action)
{
int num_unmatched = 0, i;
@@ -40,6 +41,8 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
ensure_full_index(istate);
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);
}
}
@@ -53,10 +56,26 @@ 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,
- struct index_state *istate)
+ 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, sw_action);
+ 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);
- add_pathspec_matches_against_index(pathspec, istate, seen);
+ 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;
}