pub struct ConfigHandle<'repo> { /* private fields */ }Expand description
Read merged config and update the repository-local config file.
Implementations§
Source§impl<'repo> ConfigHandle<'repo>
impl<'repo> ConfigHandle<'repo>
Sourcepub fn new(repo: &'repo Repository) -> Self
pub fn new(repo: &'repo Repository) -> Self
Bind config operations to repo.
Sourcepub fn repository(&self) -> &'repo Repository
pub fn repository(&self) -> &'repo Repository
Underlying repository.
Sourcepub fn get(&self, key: &str) -> Result<Option<String>>
pub fn get(&self, key: &str) -> Result<Option<String>>
Look up a merged config value (system / global / local / worktree cascade).
§Errors
Propagates config load failures.
§Examples
use grit_lib::repo::{InitOptions, Repository};
let dir = std::env::temp_dir().join("grit-config-get-doc");
let repo = Repository::init(&dir, &InitOptions::default())?;
let _ = repo.config_handle().get("core.repositoryformatversion");Sourcepub fn set_local(&self, key: &str, value: &str) -> Result<()>
pub fn set_local(&self, key: &str, value: &str) -> Result<()>
Set a key in the repository-local config file and reload the in-memory snapshot.
For linked worktrees this writes commondir/config when the per-worktree git directory
has no config file, matching Git’s --local target.
§Errors
Propagates config parse, validation, and I/O errors.
Sourcepub fn unset_local(&self, key: &str) -> Result<()>
pub fn unset_local(&self, key: &str) -> Result<()>
Remove key from the repository-local config file and reload the snapshot.
§Errors
Propagates config parse, validation, and I/O errors.
Trait Implementations§
Source§impl<'repo> Clone for ConfigHandle<'repo>
impl<'repo> Clone for ConfigHandle<'repo>
impl<'repo> Copy for ConfigHandle<'repo>
Auto Trait Implementations§
impl<'repo> !RefUnwindSafe for ConfigHandle<'repo>
impl<'repo> !UnwindSafe for ConfigHandle<'repo>
impl<'repo> Freeze for ConfigHandle<'repo>
impl<'repo> Send for ConfigHandle<'repo>
impl<'repo> Sync for ConfigHandle<'repo>
impl<'repo> Unpin for ConfigHandle<'repo>
impl<'repo> UnsafeUnpin for ConfigHandle<'repo>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more