Skip to content

Add gix::open_with_environment_overrides #2106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions gix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,24 @@ pub fn discover(directory: impl AsRef<std::path::Path>) -> Result<Repository, di
ThreadSafeRepository::discover(directory).map(Into::into)
}

/// See [`ThreadSafeRepository::discover_with_environment_overrides()`], but returns a [`Repository`] instead.
///
/// Use this method if you want a [`Repository`], but don't require it to be `Sync`.
#[allow(clippy::result_large_err)]
pub fn discover_with_environment_overrides(
directory: impl AsRef<std::path::Path>,
) -> Result<Repository, discover::Error> {
ThreadSafeRepository::discover_with_environment_overrides(directory).map(Into::into)
}

/// See [`ThreadSafeRepository::open_with_environment_overrides()`], but returns a [`Repository`] instead.
///
/// Use this method if you want a [`Repository`], but don't require it to be `Sync`.
#[allow(clippy::result_large_err)]
pub fn open_with_environment_overrides(directory: impl Into<std::path::PathBuf>) -> Result<Repository, open::Error> {
ThreadSafeRepository::open_with_environment_overrides(directory, Default::default()).map(Into::into)
}

/// See [`ThreadSafeRepository::init()`], but returns a [`Repository`] instead.
#[allow(clippy::result_large_err)]
pub fn init(directory: impl AsRef<std::path::Path>) -> Result<Repository, init::Error> {
Expand Down
4 changes: 3 additions & 1 deletion gix/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ pub struct Reference<'r> {

/// A thread-local handle to interact with a repository from a single thread.
///
/// It is `Send` but **not** `Sync` - for the latter you can convert it `to_sync()`.
/// It is `Send`, but **not** `Sync` - for the latter you can convert it using
/// [`.into_sync()`][Repository::into_sync()].
///
/// Note that it clones itself so that it is empty, requiring the user to configure each clone separately, specifically
/// and explicitly. This is to have the fastest-possible default configuration available by default, but allow
/// those who experiment with workloads to get speed boosts of 2x or more.
Expand Down
Loading