MCPcopy Create free account
hub / github.com/git/git / clean_shared_index_files

Function clean_shared_index_files

read-cache.c:3212–3239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3210}
3211
3212static 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
3241static int write_shared_index(struct index_state *istate,
3242 struct tempfile **temp, unsigned flags)

Callers 1

write_shared_indexFunction · 0.85

Calls 8

opendirFunction · 0.85
repo_get_git_dirFunction · 0.85
error_errnoFunction · 0.85
readdirFunction · 0.85
repo_git_pathFunction · 0.85
warning_errnoFunction · 0.85
closedirFunction · 0.85

Tested by

no test coverage detected