| 3119 | } |
| 3120 | |
| 3121 | static int do_write_locked_index(struct index_state *istate, |
| 3122 | struct lock_file *lock, |
| 3123 | unsigned flags, |
| 3124 | enum write_extensions write_extensions) |
| 3125 | { |
| 3126 | int ret; |
| 3127 | int was_full = istate->sparse_index == INDEX_EXPANDED; |
| 3128 | |
| 3129 | ret = convert_to_sparse(istate, 0); |
| 3130 | |
| 3131 | if (ret) { |
| 3132 | warning(_("failed to convert to a sparse-index")); |
| 3133 | return ret; |
| 3134 | } |
| 3135 | |
| 3136 | trace2_region_enter_printf("index", "do_write_index", istate->repo, |
| 3137 | "%s", get_lock_file_path(lock)); |
| 3138 | ret = do_write_index(istate, lock->tempfile, write_extensions, flags); |
| 3139 | trace2_region_leave_printf("index", "do_write_index", istate->repo, |
| 3140 | "%s", get_lock_file_path(lock)); |
| 3141 | |
| 3142 | if (was_full) |
| 3143 | ensure_full_index(istate); |
| 3144 | |
| 3145 | if (ret) |
| 3146 | return ret; |
| 3147 | if (flags & COMMIT_LOCK) |
| 3148 | ret = commit_locked_index(lock); |
| 3149 | else |
| 3150 | ret = close_lock_file_gently(lock); |
| 3151 | |
| 3152 | run_hooks_l(the_repository, "post-index-change", |
| 3153 | istate->updated_workdir ? "1" : "0", |
| 3154 | istate->updated_skipworktree ? "1" : "0", NULL); |
| 3155 | istate->updated_workdir = 0; |
| 3156 | istate->updated_skipworktree = 0; |
| 3157 | |
| 3158 | return ret; |
| 3159 | } |
| 3160 | |
| 3161 | static int write_split_index(struct index_state *istate, |
| 3162 | struct lock_file *lock, |
no test coverage detected