summaryrefslogtreecommitdiff
path: root/src/worktree.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/worktree.c')
-rw-r--r--src/worktree.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/worktree.c b/src/worktree.c
index 4b18db7d6..898c23434 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -139,7 +139,8 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
if ((wt->name = git__strdup(name)) == NULL
|| (wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL
|| (wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL
- || (wt->parent_path = git__strdup(parent)) == NULL) {
+ || (wt->parent_path = git__strdup(parent)) == NULL
+ || (wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
error = -1;
goto out;
}
@@ -223,6 +224,7 @@ void git_worktree_free(git_worktree *wt)
return;
git__free(wt->commondir_path);
+ git__free(wt->worktree_path);
git__free(wt->gitlink_path);
git__free(wt->gitdir_path);
git__free(wt->parent_path);
@@ -455,6 +457,18 @@ out:
return ret;
}
+const char *git_worktree_name(const git_worktree *wt)
+{
+ assert(wt);
+ return wt->name;
+}
+
+const char *git_worktree_path(const git_worktree *wt)
+{
+ assert(wt);
+ return wt->worktree_path;
+}
+
int git_worktree_prune_init_options(
git_worktree_prune_options *opts,
unsigned int version)