| 2500 | } |
| 2501 | |
| 2502 | void 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 | |
| 2541 | static int create_default_files(struct repository *repo, |
| 2542 | const char *template_path, |
no test coverage detected