| 3239 | } |
| 3240 | |
| 3241 | static int write_shared_index(struct index_state *istate, |
| 3242 | struct tempfile **temp, unsigned flags) |
| 3243 | { |
| 3244 | struct split_index *si = istate->split_index; |
| 3245 | int ret, was_full = !istate->sparse_index; |
| 3246 | char *path; |
| 3247 | |
| 3248 | move_cache_to_base_index(istate); |
| 3249 | convert_to_sparse(istate, 0); |
| 3250 | |
| 3251 | trace2_region_enter_printf("index", "shared/do_write_index", |
| 3252 | the_repository, "%s", get_tempfile_path(*temp)); |
| 3253 | ret = do_write_index(si->base, *temp, WRITE_NO_EXTENSION, flags); |
| 3254 | trace2_region_leave_printf("index", "shared/do_write_index", |
| 3255 | the_repository, "%s", get_tempfile_path(*temp)); |
| 3256 | |
| 3257 | if (was_full) |
| 3258 | ensure_full_index(istate); |
| 3259 | |
| 3260 | if (ret) |
| 3261 | return ret; |
| 3262 | ret = adjust_shared_perm(the_repository, get_tempfile_path(*temp)); |
| 3263 | if (ret) { |
| 3264 | error(_("cannot fix permission bits on '%s'"), get_tempfile_path(*temp)); |
| 3265 | return ret; |
| 3266 | } |
| 3267 | |
| 3268 | path = repo_git_path(the_repository, "sharedindex.%s", oid_to_hex(&si->base->oid)); |
| 3269 | ret = rename_tempfile(temp, path); |
| 3270 | if (!ret) { |
| 3271 | oidcpy(&si->base_oid, &si->base->oid); |
| 3272 | clean_shared_index_files(oid_to_hex(&si->base->oid)); |
| 3273 | } |
| 3274 | |
| 3275 | free(path); |
| 3276 | return ret; |
| 3277 | } |
| 3278 | |
| 3279 | static const int default_max_percent_split_change = 20; |
| 3280 |
no test coverage detected