Open a repository, optionally at a specific path. If `path` is provided, opens the repository at that path. If `path` is `None`, searches upward from the current directory. # Arguments `path` - Optional path to the repository # Returns An open [`Repository`] handle. # Errors Returns an error if no repository is found or if the repository cannot be opened. # Example ```rust,ignore // Open
(path: Option<&Path>)
| 383 | /// let repo = open_repository(Some(Path::new("/home/user/project")))?; |
| 384 | /// ``` |
| 385 | pub fn open_repository(path: Option<&Path>) -> CliResult<Repository> { |
| 386 | let repo_path = match path { |
| 387 | Some(p) => find_repository_root_from(p)?, |
| 388 | None => find_repository_root()?, |
| 389 | }; |
| 390 | |
| 391 | Repository::open(&repo_path).map_err(CliError::from) |
| 392 | } |
| 393 | |
| 394 | /// Open a repository without migration, recovery, or table-initialization writes. |
| 395 | pub fn open_repository_readonly(path: Option<&Path>) -> CliResult<Repository> { |
no test coverage detected