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

Function expand_index

sparse-index.c:323–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323void expand_index(struct index_state *istate, struct pattern_list *pl)
324{
325 int i;
326 struct index_state *full;
327 struct strbuf base = STRBUF_INIT;
328 const char *tr_region;
329 struct modify_index_context ctx;
330
331 /*
332 * If the index is already full, then keep it full. We will convert
333 * it to a sparse index on write, if possible.
334 */
335 if (istate->sparse_index == INDEX_EXPANDED)
336 return;
337
338 /*
339 * If our index is sparse, but our new pattern set does not use
340 * cone mode patterns, then we need to expand the index before we
341 * continue. A NULL pattern set indicates a full expansion to a
342 * full index.
343 */
344 if (pl && !pl->use_cone_patterns) {
345 pl = NULL;
346 } else {
347 /*
348 * We might contract file entries into sparse-directory
349 * entries, and for that we will need the cache tree to
350 * be recomputed.
351 */
352 cache_tree_free(&istate->cache_tree);
353
354 /*
355 * If there is a problem creating the cache tree, then we
356 * need to expand to a full index since we cannot satisfy
357 * the current request as a sparse index.
358 */
359 if (cache_tree_update(istate, 0))
360 pl = NULL;
361 }
362
363 if (!pl && give_advice_on_expansion) {
364 give_advice_on_expansion = 0;
365 advise_if_enabled(ADVICE_SPARSE_INDEX_EXPANDED,
366 _(ADVICE_MSG));
367 }
368
369 /*
370 * A NULL pattern set indicates we are expanding a full index, so
371 * we use a special region name that indicates the full expansion.
372 * This is used by test cases, but also helps to differentiate the
373 * two cases.
374 */
375 tr_region = pl ? "expand_index" : "ensure_full_index";
376 trace2_region_enter("index", tr_region, istate->repo);
377
378 /* initialize basics of new index */
379 full = xcalloc(1, sizeof(struct index_state));
380 memcpy(full, istate, sizeof(struct index_state));

Callers 2

update_sparsityFunction · 0.85
ensure_full_indexFunction · 0.85

Calls 14

cache_tree_freeFunction · 0.85
cache_tree_updateFunction · 0.85
advise_if_enabledFunction · 0.85
xcallocFunction · 0.85
warningFunction · 0.85
lookup_treeFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_addFunction · 0.85
read_tree_atFunction · 0.85
discard_cache_entryFunction · 0.85
ewah_freeFunction · 0.85

Tested by

no test coverage detected