* get the main worktree */
| 112 | * get the main worktree |
| 113 | */ |
| 114 | static 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 | |
| 141 | struct worktree *get_linked_worktree(const char *id, |
| 142 | int skip_reading_head) |
no test coverage detected