summaryrefslogtreecommitdiff
path: root/include/git2/worktree.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-05-02 10:11:28 +0200
committerPatrick Steinhardt <ps@pks.im>2017-05-05 15:39:25 +0200
commit8264a30f4fbfce96f433f01fa6fe537e5cb3570d (patch)
treea944129c72e1f6a7268d96ad2e285948ff87be06 /include/git2/worktree.h
parenta7aa73a535a7f21357e9c7dece8376f30a29681f (diff)
downloadlibgit2-8264a30f4fbfce96f433f01fa6fe537e5cb3570d.tar.gz
worktree: support creating locked worktrees
When creating a new worktree, we do have a potential race with us creating the worktree and another process trying to delete the same worktree as it is being created. As such, the upstream git project has introduced a flag `git worktree add --locked`, which will cause the newly created worktree to be locked immediately after its creation. This mitigates the race condition. We want to be able to mirror the same behavior. As such, a new flag `locked` is added to the options structure of `git_worktree_add` which allows the user to enable this behavior.
Diffstat (limited to 'include/git2/worktree.h')
-rw-r--r--include/git2/worktree.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/git2/worktree.h b/include/git2/worktree.h
index bc1e40243..84e2bc92e 100644
--- a/include/git2/worktree.h
+++ b/include/git2/worktree.h
@@ -76,10 +76,12 @@ GIT_EXTERN(int) git_worktree_validate(const git_worktree *wt);
typedef struct git_worktree_add_options {
unsigned int version;
+
+ char lock; /**< lock newly created worktree */
} git_worktree_add_options;
#define GIT_WORKTREE_ADD_OPTIONS_VERSION 1
-#define GIT_WORKTREE_ADD_OPTIONS_INIT {GIT_WORKTREE_ADD_OPTIONS_VERSION}
+#define GIT_WORKTREE_ADD_OPTIONS_INIT {GIT_WORKTREE_ADD_OPTIONS_VERSION,0}
/**
* Initializes a `git_worktree_add_options` with default vaules.