summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2015-10-21 13:49:55 +0200
committerPatrick Steinhardt <ps@pks.im>2017-02-13 10:59:16 +0100
commit372dc9ff6ada409204b7c3de882e5dad16f30b36 (patch)
tree7d8535481186bc1cb9060d3083d37bf76b2046d5 /include/git2
parent8c8d726ef784b3f47ed3cd9427202a74563f626e (diff)
downloadlibgit2-372dc9ff6ada409204b7c3de882e5dad16f30b36.tar.gz
worktree: implement `git_worktree_validate`
Add a new function that checks wether a given `struct git_worktree` is valid. The validation includes checking if the gitdir, parent directory and common directory are present.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/errors.h1
-rw-r--r--include/git2/worktree.h12
2 files changed, 13 insertions, 0 deletions
diff --git a/include/git2/errors.h b/include/git2/errors.h
index e959ffd8a..1d271366f 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -100,6 +100,7 @@ typedef enum {
GITERR_REBASE,
GITERR_FILESYSTEM,
GITERR_PATCH,
+ GITERR_WORKTREE
} git_error_t;
/**
diff --git a/include/git2/worktree.h b/include/git2/worktree.h
index 8313265d5..c6ca30bcd 100644
--- a/include/git2/worktree.h
+++ b/include/git2/worktree.h
@@ -49,6 +49,18 @@ GIT_EXTERN(int) git_worktree_lookup(git_worktree **out, git_repository *repo, co
*/
GIT_EXTERN(void) git_worktree_free(git_worktree *wt);
+/**
+ * Check if worktree is valid
+ *
+ * A valid worktree requires both the git data structures inside
+ * the linked parent repository and the linked working copy to be
+ * present.
+ *
+ * @param wt Worktree to check
+ * @return 0 when worktree is valid, error-code otherwise
+ */
+GIT_EXTERN(int) git_worktree_validate(const git_worktree *wt);
+
/** @} */
GIT_END_DECL
#endif