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

Function check_casefolding_conflict

submodule.c:2263–2303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2261}
2262
2263static int check_casefolding_conflict(const char *git_dir,
2264 const char *submodule_name,
2265 const bool suffixes_match)
2266{
2267 char *p, *modules_dir = xstrdup(git_dir);
2268 struct dirent *de;
2269 DIR *dir = NULL;
2270 int ret = 0;
2271
2272 if ((p = find_last_dir_sep(modules_dir)))
2273 *p = '\0';
2274
2275 /* No conflict is possible if modules_dir doesn't exist (first clone) */
2276 if (!is_directory(modules_dir))
2277 goto cleanup;
2278
2279 dir = opendir(modules_dir);
2280 if (!dir) {
2281 ret = -1;
2282 goto cleanup;
2283 }
2284
2285 /* Check for another directory under .git/modules that differs only in case. */
2286 while ((de = readdir(dir))) {
2287 if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
2288 continue;
2289
2290 if ((suffixes_match || is_git_directory(git_dir)) &&
2291 !strcasecmp(de->d_name, submodule_name) &&
2292 strcmp(de->d_name, submodule_name)) {
2293 ret = -1; /* collision found */
2294 break;
2295 }
2296 }
2297
2298cleanup:
2299 if (dir)
2300 closedir(dir);
2301 free(modules_dir);
2302 return ret;
2303}
2304
2305struct submodule_from_gitdir_cb {
2306 const char *gitdir;

Callers 1

Calls 6

xstrdupFunction · 0.85
is_directoryFunction · 0.85
opendirFunction · 0.85
readdirFunction · 0.85
is_git_directoryFunction · 0.85
closedirFunction · 0.85

Tested by

no test coverage detected