git-2.22.0/repository.c
/*
 * Initialize 'repo' based on the provided 'gitdir'.
 * Return 0 upon success and a non-zero value upon failure.
 */
Initialize 'repo' based on the provided 'gitdir'.
Return 0 upon success and a non-zero value upon failure.
Initialize ' repo ' based on the provided ' gitdir ' . Return 0 upon success and a non - zero value upon failure .
int repo_init(struct repository *repo,
	      const char *gitdir,
	      const char *worktree)
{
	struct repository_format format = REPOSITORY_FORMAT_INIT;
	memset(repo, 0, sizeof(*repo));
	repo->objects = raw_object_store_new();
	repo->parsed_objects = parsed_object_pool_new();
	if (repo_init_gitdir(repo, gitdir))
		goto error;
	if (read_and_verify_repository_format(&format, repo->commondir))
		goto error;
	repo_set_hash_algo(repo, format.hash_algo);
	if (worktree)
		repo_set_worktree(repo, worktree);
	clear_repository_format(&format);
	return 0;
error:
	repo_clear(repo);
	return -1;
}
int repo_init ( struct repository * repo , const char * gitdir , const char * worktree ) { struct repository_format format = REPOSITORY_FORMAT_INIT ; memset ( repo , 0 , sizeof ( * repo ) ) ; repo -> objects = raw_object_store_new ( ) ; repo -> parsed_objects = parsed_object_pool_new ( ) ; if ( repo_init_gitdir ( repo , gitdir ) ) goto error ; if ( read_and_verify_repository_format ( & format , repo -> commondir ) ) goto error ; repo_set_hash_algo ( repo , format . hash_algo ) ; if ( worktree ) repo_set_worktree ( repo , worktree ) ; clear_repository_format ( & format ) ; return 0 ; error : repo_clear ( repo ) ; return -1 ; }
Initialize 'repo' based on the provided 'gitdir'.
Initialize ' repo ' based on the provided ' gitdir ' .