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

Function create_default_files

setup.c:2541–2635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2539}
2540
2541static int create_default_files(struct repository *repo,
2542 const char *template_path,
2543 const char *original_git_dir,
2544 const struct repository_format *fmt,
2545 int init_shared_repository)
2546{
2547 struct stat st1;
2548 struct strbuf path = STRBUF_INIT;
2549 int reinit;
2550 int filemode;
2551 const char *work_tree = repo_get_work_tree(repo);
2552
2553 /*
2554 * First copy the templates -- we might have the default
2555 * config file there, in which case we would want to read
2556 * from it after installing.
2557 *
2558 * Before reading that config, we also need to clear out any cached
2559 * values (since we've just potentially changed what's available on
2560 * disk).
2561 */
2562 copy_templates(repo, template_path);
2563 repo_config_clear(repo);
2564 repo_settings_reset_shared_repository(repo);
2565 repo_config(repo, git_default_config, NULL);
2566
2567 reinit = is_reinit(repo);
2568
2569 /*
2570 * We must make sure command-line options continue to override any
2571 * values we might have just re-read from the config.
2572 */
2573 if (init_shared_repository != -1)
2574 repo_settings_set_shared_repository(repo,
2575 init_shared_repository);
2576
2577 is_bare_repository_cfg = !work_tree;
2578
2579 /*
2580 * We would have created the above under user's umask -- under
2581 * shared-repository settings, we would need to fix them up.
2582 */
2583 if (repo_settings_get_shared_repository(repo)) {
2584 adjust_shared_perm(repo, repo_get_git_dir(repo));
2585 }
2586
2587 initialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format, reinit);
2588
2589 /* Check filemode trustability */
2590 repo_git_path_replace(repo, &path, "config");
2591 filemode = TEST_FILEMODE;
2592 if (TEST_FILEMODE && !lstat(path.buf, &st1)) {
2593 struct stat st2;
2594 filemode = (!chmod(path.buf, st1.st_mode ^ S_IXUSR) &&
2595 !lstat(path.buf, &st2) &&
2596 st1.st_mode != st2.st_mode &&
2597 !chmod(path.buf, st1.st_mode));
2598 if (filemode && !reinit && (st1.st_mode & S_IXUSR))

Callers 1

init_dbFunction · 0.85

Calls 15

repo_get_work_treeFunction · 0.85
copy_templatesFunction · 0.85
repo_config_clearFunction · 0.85
is_reinitFunction · 0.85
adjust_shared_permFunction · 0.85
repo_get_git_dirFunction · 0.85
repo_git_path_replaceFunction · 0.85
repo_config_setFunction · 0.85

Tested by

no test coverage detected