diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index 06e1715d04..2ea565284f 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -200,6 +200,8 @@ git_enum! { GIT_EOWNER = -36, GIT_TIMEOUT = -37, GIT_EUNCHANGED = -38, + GIT_ENOTSUPPORTED = -39, + GIT_EREADONLY = -40, } } @@ -878,7 +880,8 @@ git_enum! { GIT_CONFIG_LEVEL_XDG = 3, GIT_CONFIG_LEVEL_GLOBAL = 4, GIT_CONFIG_LEVEL_LOCAL = 5, - GIT_CONFIG_LEVEL_APP = 6, + GIT_CONFIG_LEVEL_WORKTREE = 6, + GIT_CONFIG_LEVEL_APP = 7, GIT_CONFIG_HIGHEST_LEVEL = -1, } } @@ -1974,6 +1977,7 @@ git_enum! { pub struct git_worktree_add_options { pub version: c_uint, pub lock: c_int, + pub checkout_existing: c_int, pub reference: *mut git_reference, pub checkout_options: git_checkout_options, } diff --git a/src/worktree.rs b/src/worktree.rs index 569b639cf9..fc32902db1 100644 --- a/src/worktree.rs +++ b/src/worktree.rs @@ -165,6 +165,12 @@ impl<'a> WorktreeAddOptions<'a> { self } + /// If enabled, this will checkout the existing branch matching the worktree name. + pub fn checkout_existing(&mut self, enabled: bool) -> &mut WorktreeAddOptions<'a> { + self.raw.checkout_existing = enabled as c_int; + self + } + /// reference to use for the new worktree HEAD pub fn reference( &mut self, diff --git a/systest/build.rs b/systest/build.rs index 85e8b4b437..0a22a5b396 100644 --- a/systest/build.rs +++ b/systest/build.rs @@ -25,7 +25,9 @@ fn main() { // this field is marked as const which ctest complains about (struct_ == "git_rebase_operation" && f == "id") || // the real name of this field is ref but that is a reserved keyword - (struct_ == "git_worktree_add_options" && f == "reference") + (struct_ == "git_worktree_add_options" && f == "reference") || + // the `update_flags` field consists of 2 bitfields + (struct_ == "git_fetch_options" && f == "update_flags") }); cfg.skip_signededness(|s| match s { s if s.ends_with("_cb") => true,