| 750 | |
| 751 | |
| 752 | int 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 | |
| 783 | out: |
| 784 | rollback_lock_file(&lock_file); |
| 785 | return ret; |
| 786 | } |
| 787 | |
| 788 | static void prime_cache_tree_sparse_dir(struct cache_tree *it, |
| 789 | struct tree *tree) |
no test coverage detected