mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 11:06:32 +00:00
Allow user checkout options on git_worktree_add
Extend the `git_worktree_add_options` to include `git_checkout_options`. github issue #5949
This commit is contained in:
committed by
Edward Thomson
parent
a50bbba189
commit
ffead01228
@@ -86,10 +86,15 @@ typedef struct git_worktree_add_options {
|
||||
|
||||
int lock; /**< lock newly created worktree */
|
||||
git_reference *ref; /**< reference to use for the new worktree HEAD */
|
||||
|
||||
/**
|
||||
* Options for the checkout.
|
||||
*/
|
||||
git_checkout_options checkout_opts;
|
||||
} git_worktree_add_options;
|
||||
|
||||
#define GIT_WORKTREE_ADD_OPTIONS_VERSION 1
|
||||
#define GIT_WORKTREE_ADD_OPTIONS_INIT {GIT_WORKTREE_ADD_OPTIONS_VERSION,0,NULL}
|
||||
#define GIT_WORKTREE_ADD_OPTIONS_INIT {GIT_WORKTREE_ADD_OPTIONS_VERSION,0,NULL,GIT_CHECKOUT_OPTIONS_INIT}
|
||||
|
||||
/**
|
||||
* Initialize git_worktree_add_options structure
|
||||
|
||||
@@ -405,7 +405,10 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
||||
goto out;
|
||||
|
||||
/* Checkout worktree's HEAD */
|
||||
coopts.checkout_strategy = GIT_CHECKOUT_FORCE;
|
||||
if (opts != NULL)
|
||||
memcpy(&coopts, &wtopts.checkout_opts, sizeof(coopts));
|
||||
else
|
||||
coopts.checkout_strategy = GIT_CHECKOUT_FORCE;
|
||||
if ((err = git_checkout_head(wt, &coopts)) < 0)
|
||||
goto out;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user