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

Function set_git_work_tree

setup.c:1904–1920  ·  view source on GitHub ↗

* Note. This works only before you used a work tree. This was added * primarily to support git-clone to work in a new repository it just * created, and is not meant to flip between different work trees. */

Source from the content-addressed store, hash-verified

1902 * created, and is not meant to flip between different work trees.
1903 */
1904void set_git_work_tree(struct repository *repo, const char *new_work_tree)
1905{
1906 if (repo->worktree_initialized) {
1907 struct strbuf realpath = STRBUF_INIT;
1908
1909 strbuf_realpath(&realpath, new_work_tree, 1);
1910 new_work_tree = realpath.buf;
1911 if (strcmp(new_work_tree, repo->worktree))
1912 die("internal error: work tree has already been set\n"
1913 "Current worktree: %s\nNew worktree: %s",
1914 repo->worktree, new_work_tree);
1915 strbuf_release(&realpath);
1916 return;
1917 }
1918 repo->worktree_initialized = true;
1919 repo_set_worktree(repo, new_work_tree);
1920}
1921
1922const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)
1923{

Callers 4

setup_explicit_git_dirFunction · 0.85
setup_discovered_git_dirFunction · 0.85
cmd_cloneFunction · 0.85
cmd_init_dbFunction · 0.85

Calls 4

strbuf_realpathFunction · 0.85
strbuf_releaseFunction · 0.85
repo_set_worktreeFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected