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

Function prepare_to_write_split_index

split-index.c:235–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void prepare_to_write_split_index(struct index_state *istate)
236{
237 struct split_index *si = init_split_index(istate);
238 struct cache_entry **entries = NULL, *ce;
239 int i, nr_entries = 0, nr_alloc = 0;
240
241 si->delete_bitmap = ewah_new();
242 si->replace_bitmap = ewah_new();
243
244 if (si->base) {
245 /* Go through istate->cache[] and mark CE_MATCHED to
246 * entry with positive index. We'll go through
247 * base->cache[] later to delete all entries in base
248 * that are not marked with either CE_MATCHED or
249 * CE_UPDATE_IN_BASE. If istate->cache[i] is a
250 * duplicate, deduplicate it.
251 */
252 for (i = 0; i < istate->cache_nr; i++) {
253 struct cache_entry *base;
254 ce = istate->cache[i];
255 if (!ce->index) {
256 /*
257 * During simple update index operations this
258 * is a cache entry that is not present in
259 * the shared index. It will be added to the
260 * split index.
261 *
262 * However, it might also represent a file
263 * that already has a cache entry in the
264 * shared index, but a new index has just
265 * been constructed by unpack_trees(), and
266 * this entry now refers to different content
267 * than what was recorded in the original
268 * index, e.g. during 'read-tree -m HEAD^' or
269 * 'checkout HEAD^'. In this case the
270 * original entry in the shared index will be
271 * marked as deleted, and this entry will be
272 * added to the split index.
273 */
274 continue;
275 }
276 if (ce->index > si->base->cache_nr) {
277 BUG("ce refers to a shared ce at %d, which is beyond the shared index size %d",
278 ce->index, si->base->cache_nr);
279 }
280 ce->ce_flags |= CE_MATCHED; /* or "shared" */
281 base = si->base->cache[ce->index - 1];
282 if (ce == base) {
283 /* The entry is present in the shared index. */
284 if (ce->ce_flags & CE_UPDATE_IN_BASE) {
285 /*
286 * Already marked for inclusion in
287 * the split index, either because
288 * the corresponding file was
289 * modified and the cached stat data
290 * was refreshed, or because there
291 * is already a replacement entry in
292 * the split index.

Callers 1

write_split_indexFunction · 0.85

Calls 7

init_split_indexFunction · 0.85
ewah_newFunction · 0.85
is_racy_timestampFunction · 0.85
compare_ce_contentFunction · 0.85
discard_cache_entryFunction · 0.85
ewah_setFunction · 0.85
is_null_oidFunction · 0.85

Tested by

no test coverage detected