summary refs log tree commit diff
path: root/pathspec.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-05-07 12:47:39 +0900
committerJunio C Hamano <gitster@pobox.com>2021-05-07 12:47:40 +0900
commitfe069dce6251f40eb3d54861500c92afb0e481d9 (patch)
treea414af6ca4ba1fd452249ee59a85157a49bfa119 /pathspec.h
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.h')
-rw-r--r--pathspec.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/pathspec.h b/pathspec.h
index 2ccc8080b6..fceebb876f 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -149,11 +149,25 @@ static inline int ps_strcmp(const struct pathspec_item *item,
 		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,
 					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,
-					    struct index_state *istate);
+					    struct index_state *istate,
+					    enum ps_skip_worktree_action sw_action);
+char *find_pathspecs_matching_skip_worktree(const struct pathspec *pathspec);
+static inline int matches_skip_worktree(const struct pathspec *pathspec,
+					int item, char **seen_ptr)
+{
+	if (!*seen_ptr)
+		*seen_ptr = find_pathspecs_matching_skip_worktree(pathspec);
+	return (*seen_ptr)[item];
+}
 int match_pathspec_attrs(struct index_state *istate,
 			 const char *name, int namelen,
 			 const struct pathspec_item *item);