summaryrefslogtreecommitdiff
path: root/dir.h
diff options
context:
space:
mode:
authorLibravatar Derrick Stolee <dstolee@microsoft.com>2021-09-08 01:42:30 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-09-07 22:41:10 -0700
commit02155c8c005d0f8ee20a38245e9a065e8b5cc7dc (patch)
tree120fa7f3a27a8363f6c8b114342ddb4ea74c0076 /dir.h
parentsparse-index: use WRITE_TREE_MISSING_OK (diff)
downloadtgif-02155c8c005d0f8ee20a38245e9a065e8b5cc7dc.tar.xz
sparse-checkout: create helper methods
As we integrate the sparse index into more builtins, we occasionally need to check the sparse-checkout patterns to see if a path is within the sparse-checkout cone. Create some helper methods that help initialize the patterns and check for pattern matching to make this easier. The existing callers of commands like get_sparse_checkout_patterns() use a custom 'struct pattern_list' that is not necessarily the one in the 'struct index_state', so there are not many previous uses that could adopt these helpers. There are just two in builtin/add.c and sparse-index.c that can use path_in_sparse_checkout(). We add a path_in_cone_mode_sparse_checkout() as well that will only return false if the path is outside of the sparse-checkout definition _and_ the sparse-checkout patterns are in cone mode. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.h')
-rw-r--r--dir.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/dir.h b/dir.h
index b3e1a54a97..6823312521 100644
--- a/dir.h
+++ b/dir.h
@@ -394,6 +394,14 @@ enum pattern_match_result path_matches_pattern_list(const char *pathname,
const char *basename, int *dtype,
struct pattern_list *pl,
struct index_state *istate);
+
+int init_sparse_checkout_patterns(struct index_state *state);
+
+int path_in_sparse_checkout(const char *path,
+ struct index_state *istate);
+int path_in_cone_mode_sparse_checkout(const char *path,
+ struct index_state *istate);
+
struct dir_entry *dir_add_ignored(struct dir_struct *dir,
struct index_state *istate,
const char *pathname, int len);