MCPcopy Index your code
hub / github.com/git/git / get_main_worktree

Function get_main_worktree

worktree.c:114–139  ·  view source on GitHub ↗

* get the main worktree */

Source from the content-addressed store, hash-verified

112 * get the main worktree
113 */
114static struct worktree *get_main_worktree(int skip_reading_head)
115{
116 struct worktree *worktree = NULL;
117 struct strbuf worktree_path = STRBUF_INIT;
118
119 strbuf_add_real_path(&worktree_path, repo_get_common_dir(the_repository));
120 strbuf_strip_suffix(&worktree_path, "/.git");
121
122 CALLOC_ARRAY(worktree, 1);
123 worktree->repo = the_repository;
124 worktree->path = strbuf_detach(&worktree_path, NULL);
125 worktree->is_current = is_current_worktree(worktree);
126 worktree->is_bare = (is_bare_repository_cfg == 1) ||
127 is_bare_repository() ||
128 /*
129 * When in a secondary worktree we have to also verify if the main
130 * worktree is bare in $commondir/config.worktree.
131 * This check is unnecessary if we're currently in the main worktree,
132 * as prior checks already consulted all configs of the current worktree.
133 */
134 (!worktree->is_current && is_main_worktree_bare(the_repository));
135
136 if (!skip_reading_head)
137 add_head_info(worktree);
138 return worktree;
139}
140
141struct worktree *get_linked_worktree(const char *id,
142 int skip_reading_head)

Callers 1

get_worktrees_internalFunction · 0.85

Calls 8

strbuf_add_real_pathFunction · 0.85
repo_get_common_dirFunction · 0.85
strbuf_strip_suffixFunction · 0.85
strbuf_detachFunction · 0.85
is_current_worktreeFunction · 0.85
is_bare_repositoryFunction · 0.85
is_main_worktree_bareFunction · 0.85
add_head_infoFunction · 0.85

Tested by

no test coverage detected