Try to improve performance of repository open
By using `open_ext` with `BARE`, we defer loading of the Git config, which has been shown to be expensive.
This commit is contained in:
parent
8e541dcf58
commit
cce46a3d8b
|
|
@ -374,7 +374,14 @@ pub enum Validation {
|
|||
impl Repository {
|
||||
/// Open an existing repository.
|
||||
pub fn open<P: AsRef<Path>>(path: P, id: RepoId) -> Result<Self, RepositoryError> {
|
||||
let backend = git2::Repository::open_bare(path.as_ref())?;
|
||||
let backend = git2::Repository::open_ext(
|
||||
path.as_ref(),
|
||||
git2::RepositoryOpenFlags::empty()
|
||||
| git2::RepositoryOpenFlags::BARE
|
||||
| git2::RepositoryOpenFlags::NO_DOTGIT
|
||||
| git2::RepositoryOpenFlags::NO_SEARCH,
|
||||
&[] as &[&std::ffi::OsStr],
|
||||
)?;
|
||||
|
||||
Ok(Self { id, backend })
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue