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

Function write_index_as_tree

cache-tree.c:752–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750
751
752int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix)
753{
754 int entries, was_valid;
755 struct lock_file lock_file = LOCK_INIT;
756 int ret;
757
758 hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR);
759
760 entries = read_index_from(index_state, index_path,
761 repo_get_git_dir(the_repository));
762 if (entries < 0) {
763 ret = WRITE_TREE_UNREADABLE_INDEX;
764 goto out;
765 }
766
767 was_valid = !(flags & WRITE_TREE_IGNORE_CACHE_TREE) &&
768 index_state->cache_tree &&
769 cache_tree_fully_valid(index_state->cache_tree);
770
771 ret = write_index_as_tree_internal(oid, index_state, was_valid, flags,
772 prefix);
773 if (!ret && !was_valid) {
774 write_locked_index(index_state, &lock_file, COMMIT_LOCK);
775 /* Not being able to write is fine -- we are only interested
776 * in updating the cache-tree part, and if the next caller
777 * ends up using the old index with unupdated cache-tree part
778 * it misses the work we did here, but that is just a
779 * performance penalty and not a big deal.
780 */
781 }
782
783out:
784 rollback_lock_file(&lock_file);
785 return ret;
786}
787
788static void prime_cache_tree_sparse_dir(struct cache_tree *it,
789 struct tree *tree)

Callers 13

try_to_commitFunction · 0.85
do_pick_commitFunction · 0.85
fall_back_threewayFunction · 0.85
do_commitFunction · 0.85
clean_indexFunction · 0.85
do_apply_stashFunction · 0.85
save_untracked_filesFunction · 0.85
stash_stagedFunction · 0.85
stash_patchFunction · 0.85
stash_working_treeFunction · 0.85
do_create_stashFunction · 0.85
write_tree_trivialFunction · 0.85

Calls 7

read_index_fromFunction · 0.85
repo_get_git_dirFunction · 0.85
cache_tree_fully_validFunction · 0.85
write_locked_indexFunction · 0.85
rollback_lock_fileFunction · 0.85

Tested by

no test coverage detected