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

Function repo_init

repository.c:277–311  ·  view source on GitHub ↗

* Initialize 'repo' based on the provided 'gitdir'. * Return 0 upon success and a non-zero value upon failure. */

Source from the content-addressed store, hash-verified

275 * Return 0 upon success and a non-zero value upon failure.
276 */
277int repo_init(struct repository *repo,
278 const char *gitdir,
279 const char *worktree)
280{
281 struct repository_format format = REPOSITORY_FORMAT_INIT;
282 struct strbuf err = STRBUF_INIT;
283
284 memset(repo, 0, sizeof(*repo));
285
286 initialize_repository(repo);
287
288 if (repo_init_gitdir(repo, gitdir))
289 goto error;
290
291 if (read_repository_format_from_commondir(&format, repo->commondir))
292 goto error;
293
294 if (apply_repository_format(repo, &format, 0, &err) < 0) {
295 warning("%s", err.buf);
296 goto error;
297 }
298
299 if (worktree)
300 repo_set_worktree(repo, worktree);
301
302 clear_repository_format(&format);
303 strbuf_release(&err);
304 return 0;
305
306error:
307 clear_repository_format(&format);
308 strbuf_release(&err);
309 repo_clear(repo);
310 return -1;
311}
312
313int repo_submodule_init(struct repository *subrepo,
314 struct repository *superproject,

Callers 9

open_submoduleFunction · 0.85
repo_submodule_initFunction · 0.85
cmd_reconfigureFunction · 0.85
object_infoFunction · 0.85
cmd_cloneFunction · 0.85

Calls 9

initialize_repositoryFunction · 0.85
repo_init_gitdirFunction · 0.85
apply_repository_formatFunction · 0.85
warningFunction · 0.85
repo_set_worktreeFunction · 0.85
clear_repository_formatFunction · 0.85
strbuf_releaseFunction · 0.85
repo_clearFunction · 0.85

Tested by 3

object_infoFunction · 0.68