MCPcopy Create free account
hub / github.com/git/git / convert_to_sparse

Function convert_to_sparse

sparse-index.c:201–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201int convert_to_sparse(struct index_state *istate, int flags)
202{
203 /*
204 * If the index is already sparse, empty, or otherwise
205 * cannot be converted to sparse, do not convert.
206 */
207 if (istate->sparse_index == INDEX_COLLAPSED || !istate->cache_nr ||
208 !is_sparse_index_allowed(istate, flags))
209 return 0;
210
211 /*
212 * If we are purposefully collapsing a full index, then don't give
213 * advice when it is expanded later.
214 */
215 give_advice_on_expansion = 0;
216
217 /*
218 * NEEDSWORK: If we have unmerged entries, then stay full.
219 * Unmerged entries prevent the cache-tree extension from working.
220 */
221 if (index_has_unmerged_entries(istate))
222 return 0;
223
224 if (!cache_tree_fully_valid(istate->cache_tree)) {
225 /* Clear and recompute the cache-tree */
226 cache_tree_free(&istate->cache_tree);
227
228 /*
229 * Silently return if there is a problem with the cache tree update,
230 * which might just be due to a conflict state in some entry.
231 *
232 * This might create new tree objects, so be sure to use
233 * WRITE_TREE_MISSING_OK.
234 */
235 if (cache_tree_update(istate, WRITE_TREE_MISSING_OK))
236 return 0;
237 }
238
239 remove_fsmonitor(istate);
240
241 trace2_region_enter("index", "convert_to_sparse", istate->repo);
242 istate->cache_nr = convert_to_sparse_rec(istate,
243 0, 0, istate->cache_nr,
244 "", 0, istate->cache_tree);
245
246 /* Clear and recompute the cache-tree */
247 cache_tree_free(&istate->cache_tree);
248 cache_tree_update(istate, 0);
249
250 istate->fsmonitor_has_run_once = 0;
251 ewah_free(istate->fsmonitor_dirty);
252 istate->fsmonitor_dirty = NULL;
253 FREE_AND_NULL(istate->fsmonitor_last_update);
254
255 istate->sparse_index = INDEX_COLLAPSED;
256 trace2_region_leave("index", "convert_to_sparse", istate->repo);
257 return 0;
258}

Callers 5

do_write_locked_indexFunction · 0.85
write_shared_indexFunction · 0.85
ensure_correct_sparsityFunction · 0.85
sparse_checkout_cleanFunction · 0.85

Calls 8

is_sparse_index_allowedFunction · 0.85
cache_tree_fully_validFunction · 0.85
cache_tree_freeFunction · 0.85
cache_tree_updateFunction · 0.85
remove_fsmonitorFunction · 0.85
convert_to_sparse_recFunction · 0.85
ewah_freeFunction · 0.85

Tested by

no test coverage detected