Skip to content

Commit 368bc86

Browse files
committed
libgit2: Account for further API changes
1 parent 5187c9e commit 368bc86

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

libgit2-sys/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ git_enum! {
200200
GIT_EOWNER = -36,
201201
GIT_TIMEOUT = -37,
202202
GIT_EUNCHANGED = -38,
203+
GIT_ENOTSUPPORTED = -39,
204+
GIT_EREADONLY = -40,
203205
}
204206
}
205207

@@ -878,7 +880,8 @@ git_enum! {
878880
GIT_CONFIG_LEVEL_XDG = 3,
879881
GIT_CONFIG_LEVEL_GLOBAL = 4,
880882
GIT_CONFIG_LEVEL_LOCAL = 5,
881-
GIT_CONFIG_LEVEL_APP = 6,
883+
GIT_CONFIG_LEVEL_WORKTREE = 6,
884+
GIT_CONFIG_LEVEL_APP = 7,
882885
GIT_CONFIG_HIGHEST_LEVEL = -1,
883886
}
884887
}
@@ -1974,6 +1977,7 @@ git_enum! {
19741977
pub struct git_worktree_add_options {
19751978
pub version: c_uint,
19761979
pub lock: c_int,
1980+
pub checkout_existing: c_int,
19771981
pub reference: *mut git_reference,
19781982
pub checkout_options: git_checkout_options,
19791983
}

src/worktree.rs

+6
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ impl<'a> WorktreeAddOptions<'a> {
165165
self
166166
}
167167

168+
/// If enabled, this will checkout the existing branch matching the worktree name.
169+
pub fn checkout_existing(&mut self, enabled: bool) -> &mut WorktreeAddOptions<'a> {
170+
self.raw.checkout_existing = enabled as c_int;
171+
self
172+
}
173+
168174
/// reference to use for the new worktree HEAD
169175
pub fn reference(
170176
&mut self,

systest/build.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ fn main() {
2525
// this field is marked as const which ctest complains about
2626
(struct_ == "git_rebase_operation" && f == "id") ||
2727
// the real name of this field is ref but that is a reserved keyword
28-
(struct_ == "git_worktree_add_options" && f == "reference")
28+
(struct_ == "git_worktree_add_options" && f == "reference") ||
29+
// the `update_flags` field consists of 2 bitfields
30+
(struct_ == "git_fetch_options" && f == "update_flags")
2931
});
3032
cfg.skip_signededness(|s| match s {
3133
s if s.ends_with("_cb") => true,

0 commit comments

Comments
 (0)