| 67 | } |
| 68 | |
| 69 | struct worktree *get_current_worktree(struct repository *repo) |
| 70 | { |
| 71 | struct worktree *wt = xcalloc(1, sizeof(*wt)); |
| 72 | char *gitdir = absolute_pathdup(repo->gitdir); |
| 73 | char *commondir = absolute_pathdup(repo->commondir); |
| 74 | |
| 75 | wt->repo = repo; |
| 76 | wt->path = absolute_pathdup(repo->worktree ? repo->worktree |
| 77 | : repo->gitdir); |
| 78 | wt->is_bare = !repo->worktree; |
| 79 | if (fspathcmp(gitdir, commondir)) |
| 80 | wt->id = xstrdup(find_last_dir_sep(gitdir) + 1); |
| 81 | wt->is_current = true; |
| 82 | add_head_info(wt); |
| 83 | |
| 84 | free(gitdir); |
| 85 | free(commondir); |
| 86 | return wt; |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * When in a secondary worktree, and when extensions.worktreeConfig |
no test coverage detected