summaryrefslogtreecommitdiff
path: root/include/git2/worktree.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2015-10-21 13:53:18 +0200
committerPatrick Steinhardt <ps@pks.im>2017-02-13 11:02:03 +0100
commitf0cfc34105fd68af9eb6e2024459c40c45e7d3a0 (patch)
treef8487a9f042180a253e79fcc6be7c19a744b2f5f /include/git2/worktree.h
parent2a503485fae6c93c76bd0465c8b3fad5d9e19f6d (diff)
downloadlibgit2-f0cfc34105fd68af9eb6e2024459c40c45e7d3a0.tar.gz
worktree: implement `git_worktree_prune`
Implement the `git_worktree_prune` function. This function can be used to delete working trees from a repository. According to the flags passed to it, it can either delete the working tree's gitdir only or both gitdir and the working directory.
Diffstat (limited to 'include/git2/worktree.h')
-rw-r--r--include/git2/worktree.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/git2/worktree.h b/include/git2/worktree.h
index 62b4b5e79..594ff795b 100644
--- a/include/git2/worktree.h
+++ b/include/git2/worktree.h
@@ -112,6 +112,32 @@ GIT_EXTERN(int) git_worktree_unlock(git_worktree *wt);
*/
GIT_EXTERN(int) git_worktree_is_locked(git_buf *reason, const git_worktree *wt);
+/**
+ * Flags which can be passed to git_worktree_prune to alter its
+ * behavior.
+ */
+typedef enum {
+ /* Prune working tree even if working tree is valid */
+ GIT_WORKTREE_PRUNE_VALID = 1u << 0,
+ /* Prune working tree even if it is locked */
+ GIT_WORKTREE_PRUNE_LOCKED = 1u << 1,
+ /* Prune checked out working tree */
+ GIT_WORKTREE_PRUNE_WORKING_TREE = 1u << 2,
+} git_worktree_prune_t;
+
+/**
+ * Prune working tree
+ *
+ * Prune the working tree, that is remove the git data
+ * structures on disk. The repository will only be pruned of
+ * `git_worktree_is_prunable` succeeds.
+ *
+ * @param wt Worktree to prune
+ * @param flags git_worktree_prune_t flags
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_worktree_prune(git_worktree *wt, unsigned flags);
+
/** @} */
GIT_END_DECL
#endif