summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2015-10-27 12:37:51 +0100
committerPatrick Steinhardt <ps@pks.im>2017-02-13 11:03:01 +0100
commit04fb12abb24810391fa19af5696eb38629d650df (patch)
treecd926fbf2e9e3172ea9d0618efe6505e06089657 /include
parentf0cfc34105fd68af9eb6e2024459c40c45e7d3a0 (diff)
downloadlibgit2-04fb12abb24810391fa19af5696eb38629d650df.tar.gz
worktree: implement functions reading HEAD
Implement `git_repository_head_for_worktree` and `git_repository_head_detached_for_worktree` for directly accessing a worktree's HEAD without opening it as a `git_repository` first.
Diffstat (limited to 'include')
-rw-r--r--include/git2/repository.h25
-rw-r--r--include/git2/worktree.h2
2 files changed, 26 insertions, 1 deletions
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 29eb2da49..a396a5409 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -346,6 +346,17 @@ GIT_EXTERN(int) git_repository_init_ext(
GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
/**
+ * Retrieve the referenced HEAD for the worktree
+ *
+ * @param out pointer to the reference which will be retrieved
+ * @param repo a repository object
+ * @param name name of the worktree to retrieve HEAD for
+ * @return 0 when successful, error-code otherwise
+ */
+GIT_EXTERN(int) git_repository_head_for_worktree(git_reference **out, git_repository *repo,
+ const char *name);
+
+/**
* Check if a repository's HEAD is detached
*
* A repository's HEAD is detached when it points directly to a commit
@@ -357,6 +368,20 @@ GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
*/
GIT_EXTERN(int) git_repository_head_detached(git_repository *repo);
+/*
+ * Check if a worktree's HEAD is detached
+ *
+ * A worktree's HEAD is detached when it points directly to a
+ * commit instead of a branch.
+ *
+ * @param repo a repository object
+ * @param name name of the worktree to retrieve HEAD for
+ * @return 1 if HEAD is detached, 0 if its not; error code if
+ * there was an error
+ */
+GIT_EXTERN(int) git_repository_head_detached_for_worktree(git_repository *repo,
+ const char *name);
+
/**
* Check if the current branch is unborn
*
diff --git a/include/git2/worktree.h b/include/git2/worktree.h
index 594ff795b..ec869fb59 100644
--- a/include/git2/worktree.h
+++ b/include/git2/worktree.h
@@ -77,7 +77,7 @@ GIT_EXTERN(int) git_worktree_validate(const git_worktree *wt);
*/
GIT_EXTERN(int) git_worktree_add(git_worktree **out, git_repository *repo, const char *name, const char *path);
-/*
+/**
* Lock worktree if not already locked
*
* Lock a worktree, optionally specifying a reason why the linked