Skip to content

Commit

Permalink
remote: Update git_fetch_options to use bitflags instead of bitfields
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjmnt4n committed May 15, 2024
1 parent 24d0ff3 commit f0f10b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pub struct git_fetch_options {
pub version: c_int,
pub callbacks: git_remote_callbacks,
pub prune: git_fetch_prune_t,
pub update_flags: c_uint,
pub update_fetchhead: c_uint,
pub download_tags: git_remote_autotag_option_t,
pub proxy_opts: git_proxy_options,
pub depth: c_int,
Expand Down
9 changes: 4 additions & 5 deletions src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,10 @@ impl<'cb> Binding for FetchOptions<'cb> {
.map(|m| m.raw())
.unwrap_or_else(|| ProxyOptions::new().raw()),
prune: crate::call::convert(&self.prune),
// HACK: `libgit2` uses C bitfields, which do not have a guaranteed memory layout.
// Reversing the bits ensures that the bitfields are set whether the bits are laid out
// from left to right or right to left, but will not work on other memory layouts.
update_flags: (self.update_flags.bits() | self.update_flags.bits().reverse_bits())
as c_uint,
// `update_fetchhead` is an incorrectly named option which contains both
// the `UPDATE_FETCHHEAD` and `REPORT_UNCHANGED` flags.
// See https://github.com/libgit2/libgit2/pull/6806
update_fetchhead: self.update_flags.bits() as c_uint,
download_tags: crate::call::convert(&self.download_tags),
depth: self.depth,
follow_redirects: self.follow_redirects.raw(),
Expand Down
4 changes: 1 addition & 3 deletions systest/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ 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") ||
// the `update_flags` field consists of 2 bitfields
(struct_ == "git_fetch_options" && f == "update_flags")
(struct_ == "git_worktree_add_options" && f == "reference")
});
cfg.skip_signededness(|s| match s {
s if s.ends_with("_cb") => true,
Expand Down

0 comments on commit f0f10b0

Please sign in to comment.