Skip to content

Commit

Permalink
GitFetchOptions: Add hack to ensure update_flags bitfields are init…
Browse files Browse the repository at this point in the history
…ialized properly
  • Loading branch information
bnjmnt4n committed Mar 25, 2024
1 parent bb75668 commit 3c105a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,11 @@ impl<'cb> Binding for FetchOptions<'cb> {
.map(|m| m.raw())
.unwrap_or_else(|| ProxyOptions::new().raw()),
prune: crate::call::convert(&self.prune),
update_flags: self.update_flags.bits() as c_uint,
// 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,
download_tags: crate::call::convert(&self.download_tags),
depth: self.depth,
follow_redirects: self.follow_redirects.raw(),
Expand Down

0 comments on commit 3c105a7

Please sign in to comment.