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

Function repo_set_gitdir

repository.c:168–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168void repo_set_gitdir(struct repository *repo,
169 const char *root,
170 const struct set_gitdir_args *o)
171{
172 const char *gitfile = read_gitfile(root);
173 /*
174 * repo->gitdir is saved because the caller could pass "root"
175 * that also points to repo->gitdir. We want to keep it alive
176 * until after xstrdup(root). Then we can free it.
177 */
178 char *old_gitdir = repo->gitdir;
179
180 repo->gitdir = xstrdup(gitfile ? gitfile : root);
181 free(old_gitdir);
182
183 repo_set_commondir(repo, o->commondir);
184 repo->disable_ref_updates = o->disable_ref_updates;
185
186 expand_base_dir(&repo->graft_file, o->graft_file,
187 repo->commondir, "info/grafts");
188 expand_base_dir(&repo->index_file, o->index_file,
189 repo->gitdir, "index");
190}
191
192void repo_set_hash_algo(struct repository *repo, uint32_t hash_algo)
193{

Callers 2

setup_git_env_internalFunction · 0.85
repo_init_gitdirFunction · 0.85

Calls 3

xstrdupFunction · 0.85
repo_set_commondirFunction · 0.85
expand_base_dirFunction · 0.85

Tested by

no test coverage detected