Skip to content

Commit 3c105a7

Browse files
committed
GitFetchOptions: Add hack to ensure update_flags bitfields are initialized properly
1 parent bb75668 commit 3c105a7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/remote.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,11 @@ impl<'cb> Binding for FetchOptions<'cb> {
613613
.map(|m| m.raw())
614614
.unwrap_or_else(|| ProxyOptions::new().raw()),
615615
prune: crate::call::convert(&self.prune),
616-
update_flags: self.update_flags.bits() as c_uint,
616+
// HACK: `libgit2` uses C bitfields, which do not have a guaranteed memory layout.
617+
// Reversing the bits ensures that the bitfields are set whether the bits are laid out
618+
// from left to right or right to left, but will not work on other memory layouts.
619+
update_flags: (self.update_flags.bits() | self.update_flags.bits().reverse_bits())
620+
as c_uint,
617621
download_tags: crate::call::convert(&self.download_tags),
618622
depth: self.depth,
619623
follow_redirects: self.follow_redirects.raw(),

0 commit comments

Comments
 (0)