MCPcopy Index your code
hub / github.com/git/git / create_reference_database

Function create_reference_database

setup.c:2502–2539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2500}
2501
2502void create_reference_database(struct repository *repo,
2503 const char *initial_branch, int quiet)
2504{
2505 struct strbuf err = STRBUF_INIT;
2506 char *to_free = NULL;
2507 int reinit = is_reinit(repo);
2508
2509 if (ref_store_create_on_disk(get_main_ref_store(repo), 0, &err))
2510 die("failed to set up refs db: %s", err.buf);
2511
2512 /*
2513 * Point the HEAD symref to the initial branch with if HEAD does
2514 * not yet exist.
2515 */
2516 if (!reinit) {
2517 char *ref;
2518
2519 if (!initial_branch)
2520 initial_branch = to_free =
2521 repo_default_branch_name(repo, quiet);
2522
2523 ref = xstrfmt("refs/heads/%s", initial_branch);
2524 if (check_refname_format(ref, 0) < 0)
2525 die(_("invalid initial branch name: '%s'"),
2526 initial_branch);
2527
2528 if (refs_update_symref(get_main_ref_store(repo), "HEAD", ref, NULL) < 0)
2529 exit(1);
2530 free(ref);
2531 }
2532
2533 if (reinit && initial_branch)
2534 warning(_("re-init: ignored --initial-branch=%s"),
2535 initial_branch);
2536
2537 strbuf_release(&err);
2538 free(to_free);
2539}
2540
2541static int create_default_files(struct repository *repo,
2542 const char *template_path,

Callers 2

init_dbFunction · 0.85
cmd_cloneFunction · 0.85

Calls 10

is_reinitFunction · 0.85
ref_store_create_on_diskFunction · 0.85
get_main_ref_storeFunction · 0.85
repo_default_branch_nameFunction · 0.85
xstrfmtFunction · 0.85
check_refname_formatFunction · 0.85
refs_update_symrefFunction · 0.85
warningFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected