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

Function get_current_worktree

worktree.c:69–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69struct 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

Callers 1

wt_status_get_stateFunction · 0.85

Calls 4

xcallocFunction · 0.85
absolute_pathdupFunction · 0.85
xstrdupFunction · 0.85
add_head_infoFunction · 0.85

Tested by

no test coverage detected