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

Function cmd_init_db

builtin/init-db.c:72–264  ·  view source on GitHub ↗

* If you want to, you can share the DB area with any number of branches. * That has advantages: you can save space by sharing all the SHA1 objects. * On the other hand, it might just make lookup slower and messier. You * be the judge. The default case is to have one DB per managed directory. */

Source from the content-addressed store, hash-verified

70 * be the judge. The default case is to have one DB per managed directory.
71 */
72int cmd_init_db(int argc,
73 const char **argv,
74 const char *prefix,
75 struct repository *repo UNUSED)
76{
77 char *git_dir;
78 const char *real_git_dir = NULL;
79 char *real_git_dir_to_free = NULL;
80 char *work_tree = NULL;
81 const char *template_dir = NULL;
82 char *template_dir_to_free = NULL;
83 unsigned int flags = 0;
84 const char *object_format = NULL;
85 const char *ref_format = NULL;
86 const char *initial_branch = NULL;
87 int hash_algo = GIT_HASH_UNKNOWN;
88 enum ref_storage_format ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;
89 int init_shared_repository = -1;
90 const struct option init_db_options[] = {
91 OPT_STRING(0, "template", &template_dir, N_("template-directory"),
92 N_("directory from which templates will be used")),
93 OPT_SET_INT(0, "bare", &is_bare_repository_cfg,
94 N_("create a bare repository"), 1),
95 {
96 .type = OPTION_CALLBACK,
97 .long_name = "shared",
98 .value = &init_shared_repository,
99 .argh = N_("permissions"),
100 .help = N_("specify that the git repository is to be shared amongst several users"),
101 .flags = PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
102 .callback = shared_callback
103 },
104 OPT_BIT('q', "quiet", &flags, N_("be quiet"), INIT_DB_QUIET),
105 OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
106 N_("separate git dir from working tree")),
107 OPT_STRING('b', "initial-branch", &initial_branch, N_("name"),
108 N_("override the name of the initial branch")),
109 OPT_STRING(0, "object-format", &object_format, N_("hash"),
110 N_("specify the hash algorithm to use")),
111 OPT_STRING(0, "ref-format", &ref_format, N_("format"),
112 N_("specify the reference format to use")),
113 OPT_END()
114 };
115 int ret;
116
117 argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
118
119 if (real_git_dir && is_bare_repository_cfg == 1)
120 die(_("options '%s' and '%s' cannot be used together"), "--separate-git-dir", "--bare");
121
122 if (real_git_dir && !is_absolute_path(real_git_dir))
123 real_git_dir = real_git_dir_to_free = real_pathdup(real_git_dir, 1);
124
125 if (template_dir && *template_dir && !is_absolute_path(template_dir))
126 template_dir = template_dir_to_free = absolute_pathdup(template_dir);
127
128 if (argc == 1) {
129 int mkdir_tried = 0;

Callers

nothing calls this directly

Calls 15

parse_optionsFunction · 0.85
is_absolute_pathFunction · 0.85
real_pathdupFunction · 0.85
absolute_pathdupFunction · 0.85
chdirFunction · 0.85
die_errnoFunction · 0.85
xgetcwdFunction · 0.85
hash_algo_by_nameFunction · 0.85

Tested by

no test coverage detected