| 3210 | } |
| 3211 | |
| 3212 | static int clean_shared_index_files(const char *current_hex) |
| 3213 | { |
| 3214 | struct dirent *de; |
| 3215 | DIR *dir = opendir(repo_get_git_dir(the_repository)); |
| 3216 | |
| 3217 | if (!dir) |
| 3218 | return error_errno(_("unable to open git dir: %s"), |
| 3219 | repo_get_git_dir(the_repository)); |
| 3220 | |
| 3221 | while ((de = readdir(dir)) != NULL) { |
| 3222 | const char *sha1_hex; |
| 3223 | char *shared_index_path; |
| 3224 | if (!skip_prefix(de->d_name, "sharedindex.", &sha1_hex)) |
| 3225 | continue; |
| 3226 | if (!strcmp(sha1_hex, current_hex)) |
| 3227 | continue; |
| 3228 | |
| 3229 | shared_index_path = repo_git_path(the_repository, "%s", de->d_name); |
| 3230 | if (should_delete_shared_index(shared_index_path) > 0 && |
| 3231 | unlink(shared_index_path)) |
| 3232 | warning_errno(_("unable to unlink: %s"), shared_index_path); |
| 3233 | |
| 3234 | free(shared_index_path); |
| 3235 | } |
| 3236 | closedir(dir); |
| 3237 | |
| 3238 | return 0; |
| 3239 | } |
| 3240 | |
| 3241 | static int write_shared_index(struct index_state *istate, |
| 3242 | struct tempfile **temp, unsigned flags) |
no test coverage detected