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

Function repo_init_gitdir

repository.c:224–250  ·  view source on GitHub ↗

* Attempt to resolve and set the provided 'gitdir' for repository 'repo'. * Return 0 upon success and a non-zero value upon failure. */

Source from the content-addressed store, hash-verified

222 * Return 0 upon success and a non-zero value upon failure.
223 */
224static int repo_init_gitdir(struct repository *repo, const char *gitdir)
225{
226 int ret = 0;
227 int error = 0;
228 char *abspath = NULL;
229 const char *resolved_gitdir;
230 struct set_gitdir_args args = { NULL };
231
232 abspath = real_pathdup(gitdir, 0);
233 if (!abspath) {
234 ret = -1;
235 goto out;
236 }
237
238 /* 'gitdir' must reference the gitdir directly */
239 resolved_gitdir = resolve_gitdir_gently(abspath, &error);
240 if (!resolved_gitdir) {
241 ret = -1;
242 goto out;
243 }
244
245 repo_set_gitdir(repo, resolved_gitdir, &args);
246
247out:
248 free(abspath);
249 return ret;
250}
251
252void repo_set_worktree(struct repository *repo, const char *path)
253{

Callers 1

repo_initFunction · 0.85

Calls 3

real_pathdupFunction · 0.85
resolve_gitdir_gentlyFunction · 0.85
repo_set_gitdirFunction · 0.85

Tested by

no test coverage detected