MCPcopy Index your code
hub / github.com/git/git / write_locked_index

Function write_locked_index

read-cache.c:3309–3392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3307}
3308
3309int write_locked_index(struct index_state *istate, struct lock_file *lock,
3310 unsigned flags)
3311{
3312 int new_shared_index, ret, test_split_index_env;
3313 struct split_index *si = istate->split_index;
3314
3315 if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0) &&
3316 cache_tree_verify(the_repository, istate) < 0)
3317 return -1;
3318
3319 if ((flags & SKIP_IF_UNCHANGED) && !istate->cache_changed) {
3320 if (flags & COMMIT_LOCK)
3321 rollback_lock_file(lock);
3322 return 0;
3323 }
3324
3325 if (istate->fsmonitor_last_update)
3326 fill_fsmonitor_bitmap(istate);
3327
3328 test_split_index_env = git_env_bool("GIT_TEST_SPLIT_INDEX", 0);
3329
3330 if ((!si && !test_split_index_env) ||
3331 alternate_index_output ||
3332 (istate->cache_changed & ~EXTMASK)) {
3333 ret = do_write_locked_index(istate, lock, flags,
3334 ~WRITE_SPLIT_INDEX_EXTENSION);
3335 goto out;
3336 }
3337
3338 if (test_split_index_env) {
3339 if (!si) {
3340 si = init_split_index(istate);
3341 istate->cache_changed |= SPLIT_INDEX_ORDERED;
3342 } else {
3343 int v = si->base_oid.hash[0];
3344 if ((v & 15) < 6)
3345 istate->cache_changed |= SPLIT_INDEX_ORDERED;
3346 }
3347 }
3348 if (too_many_not_shared_entries(istate))
3349 istate->cache_changed |= SPLIT_INDEX_ORDERED;
3350
3351 new_shared_index = istate->cache_changed & SPLIT_INDEX_ORDERED;
3352
3353 if (new_shared_index) {
3354 struct tempfile *temp;
3355 int saved_errno;
3356 char *path;
3357
3358 /* Same initial permissions as the main .git/index file */
3359 path = repo_git_path(the_repository, "sharedindex_XXXXXX");
3360 temp = mks_tempfile_sm(path, 0, 0666);
3361 free(path);
3362 if (!temp) {
3363 ret = do_write_locked_index(istate, lock, flags,
3364 ~WRITE_SPLIT_INDEX_EXTENSION);
3365 goto out;
3366 }

Callers 15

write_index_as_treeFunction · 0.85
merge_ort_genericFunction · 0.85
reset_headFunction · 0.85
checkout_fast_forwardFunction · 0.85
do_recursive_mergeFunction · 0.85
read_and_refresh_cacheFunction · 0.85
do_resetFunction · 0.85
do_mergeFunction · 0.85
update_pathsFunction · 0.85
run_updateFunction · 0.85
run_revertFunction · 0.85
run_add_untrackedFunction · 0.85

Calls 15

git_env_boolFunction · 0.85
cache_tree_verifyFunction · 0.85
rollback_lock_fileFunction · 0.85
fill_fsmonitor_bitmapFunction · 0.85
do_write_locked_indexFunction · 0.85
init_split_indexFunction · 0.85
repo_git_pathFunction · 0.85
mks_tempfile_smFunction · 0.85
write_shared_indexFunction · 0.85
is_tempfile_activeFunction · 0.85
delete_tempfileFunction · 0.85

Tested by 2

cmd__write_cacheFunction · 0.68
cmd__scrap_cache_treeFunction · 0.68