blob: 59a92d819ecdac1430b69db081b79cfc7e8ca84a [file] [log] [blame]
Derrick Stolee3964fc22021-03-30 13:10:47 +00001#ifndef SPARSE_INDEX_H__
2#define SPARSE_INDEX_H__
3
4struct index_state;
Derrick Stoleece7a9f02021-09-08 01:42:32 +00005#define SPARSE_INDEX_MEMORY_ONLY (1 << 0)
Victoria Dyecfde4cd2022-05-10 23:32:29 +00006int is_sparse_index_allowed(struct index_state *istate, int flags);
Derrick Stoleece7a9f02021-09-08 01:42:32 +00007int convert_to_sparse(struct index_state *istate, int flags);
Victoria Dyeb93fea02021-11-23 00:20:32 +00008void ensure_correct_sparsity(struct index_state *istate);
Elijah Newrenaf6a5182022-01-14 15:59:41 +00009void clear_skip_worktree_from_present_files(struct index_state *istate);
Derrick Stolee3964fc22021-03-30 13:10:47 +000010
Derrick Stolee71f82d02021-04-12 21:08:16 +000011/*
12 * Some places in the codebase expect to search for a specific path.
13 * This path might be outside of the sparse-checkout definition, in
14 * which case a sparse-index may not contain a path for that index.
15 *
16 * Given an index and a path, check to see if a leading directory for
17 * 'path' exists in the index as a sparse directory. In that case,
18 * expand that sparse directory to a full range of cache entries and
19 * populate the index accordingly.
20 */
21void expand_to_path(struct index_state *istate,
22 const char *path, size_t pathlen, int icase);
23
Derrick Stolee122ba1f2021-03-30 13:11:00 +000024struct repository;
25int set_sparse_index_config(struct repository *repo, int enable);
26
Derrick Stoleedce241b2022-05-23 13:48:39 +000027struct pattern_list;
28
29/**
30 * Scan the given index and compare its entries to the given pattern list.
31 * If the index is sparse and the pattern list uses cone mode patterns,
32 * then modify the index to contain the all of the file entries within that
33 * new pattern list. This expands sparse directories only as far as needed.
34 *
35 * If the pattern list is NULL or does not use cone mode patterns, then the
36 * index is expanded to a full index.
37 */
38void expand_index(struct index_state *istate, struct pattern_list *pl);
39
Derrick Stolee3964fc22021-03-30 13:10:47 +000040#endif