summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-03-15 14:24:25 +0100
committerPatrick Steinhardt <ps@pks.im>2017-03-17 09:26:13 +0100
commit3017ba94a33a5dae07521afd96a94e21afb07b8c (patch)
treed80c60c55024b1d92ff1858e6d0ea2e5b78b12f2 /include/git2
parentdfc98706479c252c023ba093b690c6202a5021e5 (diff)
downloadlibgit2-3017ba94a33a5dae07521afd96a94e21afb07b8c.tar.gz
worktree: implement `git_worktree_open_from_repository`
While we already provide functionality to look up a worktree from a repository, we cannot do so the other way round. That is given a repository, we want to look up its worktree if it actually exists. Getting the worktree of a repository is useful when we want to get certain meta information like the parent's location, getting the locked status, etc.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/worktree.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/git2/worktree.h b/include/git2/worktree.h
index cad1284fa..4c4f9284d 100644
--- a/include/git2/worktree.h
+++ b/include/git2/worktree.h
@@ -44,6 +44,18 @@ GIT_EXTERN(int) git_worktree_list(git_strarray *out, git_repository *repo);
GIT_EXTERN(int) git_worktree_lookup(git_worktree **out, git_repository *repo, const char *name);
/**
+ * Open a worktree of a given repository
+ *
+ * If a repository is not the main tree but a worktree, this
+ * function will look up the worktree inside the parent
+ * repository and create a new `git_worktree` structure.
+ *
+ * @param out Out-pointer for the newly allocated worktree
+ * @param repo Repository to look up worktree for
+ */
+GIT_EXTERN(int) git_worktree_open_from_repository(git_worktree **out, git_repository *repo);
+
+/**
* Free a previously allocated worktree
*
* @param wt worktree handle to close. If NULL nothing occurs.