From dba8c6b2341274b27e9c9ae1918feec4b6cf6f23 Mon Sep 17 00:00:00 2001 From: wiiznokes <78230769+wiiznokes@users.noreply.github.com> Date: Mon, 1 Jun 2026 11:30:12 +0200 Subject: [PATCH] add set_homedir function --- src/opts.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/opts.rs b/src/opts.rs index 232d81e996..06c3baa47f 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -471,6 +471,22 @@ pub unsafe fn set_server_timeout_in_milliseconds(timeout: libc::c_int) -> Result Ok(()) } +/// Sets the directory used as the current user's home directory, for file lookups +/// +/// # Safety +/// This function is modifying a C global without synchronization, so it is not +/// thread safe, and should only be called before any thread is spawned. +pub unsafe fn set_homedir(homedir: std::ffi::CString) -> Result<(), Error> { + crate::init(); + + try_call!(raw::git_libgit2_opts( + raw::GIT_OPT_SET_HOMEDIR as libc::c_int, + homedir.as_ptr() + )); + + Ok(()) +} + #[cfg(test)] mod test { use super::*;