| @@ -29,7 +29,7 @@ · 28 unmodified lines |
| 29 | 29 | //! |
| 30 | 30 | //! By default, the [`Repository`] isn't `Sync` and thus can't be used in certain contexts which require the `Sync` trait. |
| 31 | 31 | //! |
| 32 | | −//! To help with this, convert it with [`.into_sync()`][Repository::into_sync()] into a [`ThreadSafeRepository`]. |
| 32 | +//! To help with this, convert it with [`Repository::into_sync()`] into a [`ThreadSafeRepository`]. |
| 33 | 33 | //! |
| 34 | 34 | //! ### Object-Access Performance |
| 35 | 35 | //! |
| @@ -41,7 +41,7 @@ · 5 unmodified lines |
| 41 | 41 | //! On miss, the object is looked up and if a pack is hit, there is a small fixed-size cache for delta-base objects. |
| 42 | 42 | //! |
| 43 | 43 | //! In scenarios where the same objects are accessed multiple times, the object cache can be useful and is to be configured specifically |
| 44 | | −//! using the [`object_cache_size(…)`][crate::Repository::object_cache_size()] method. |
| 44 | +//! using the [`Repository::object_cache_size()`] method. |
| 45 | 45 | //! |
| 46 | 46 | //! Use the `cache-efficiency-debug` cargo feature to learn how efficient the cache actually is - it's easy to end up with lowered |
| 47 | 47 | //! performance if the cache is not hit in 50% of the time. |
| @@ -207,7 +207,10 @@ pub mod diff; · 159 unmodified lines |
| 207 | 207 | #[cfg(feature = "merge")] |
| 208 | 208 | pub mod merge; |
| 209 | 209 | |
| 210 | | −/// See [`ThreadSafeRepository::discover()`], but returns a [`Repository`] instead. |
| 210 | +/// Try to open a git repository in `directory` and search upwards through its parents until one is found, |
| 211 | +/// using default trust options which matters in case the found repository isn't owned by the current user. |
| 212 | +/// |
| 213 | +/// For details, see [`ThreadSafeRepository::discover()`]. |
| 211 | 214 | /// |
| 212 | 215 | /// # Note |
| 213 | 216 | /// |
| @@ -222,6 +225,24 @@ pub fn discover(directory: impl AsRef<std::path::Path>) -> Result<Repository, di · 8 unmodified lines |
| 222 | 225 | ThreadSafeRepository::discover(directory).map(Into::into) |
| 223 | 226 | } |
| 224 | 227 | |
| 228 | +/// Try to discover a git repository directly from the environment. |
| 229 | +/// |
| 230 | +/// For details, see [`ThreadSafeRepository::discover_with_environment_overrides_opts()`]. |
| 231 | +#[allow(clippy::result_large_err)] |
| 232 | +pub fn discover_with_environment_overrides( |
| 233 | + directory: impl AsRef<std::path::Path>, |
| 234 | +) -> Result<Repository, discover::Error> { |
| 235 | + ThreadSafeRepository::discover_with_environment_overrides(directory).map(Into::into) |
| 236 | +} |
| 237 | + |
| 238 | +/// Try to open a git repository directly from the environment. |
| 239 | +/// |
| 240 | +/// See [`ThreadSafeRepository::open_with_environment_overrides()`]. |
| 241 | +#[allow(clippy::result_large_err)] |
| 242 | +pub fn open_with_environment_overrides(directory: impl Into<std::path::PathBuf>) -> Result<Repository, open::Error> { |
| 243 | + ThreadSafeRepository::open_with_environment_overrides(directory, Default::default()).map(Into::into) |
| 244 | +} |
| 245 | + |
| 225 | 246 | /// See [`ThreadSafeRepository::init()`], but returns a [`Repository`] instead. |
| 226 | 247 | #[allow(clippy::result_large_err)] |
| 227 | 248 | pub fn init(directory: impl AsRef<std::path::Path>) -> Result<Repository, init::Error> { |