@@ -147,7 +147,7 @@ pub trait Fs: Send + Sync {
&self,
abs_dot_git: &Path,
system_git_binary_path: Option<&Path>,
- ) -> Option<Arc<dyn GitRepository>>;
+ ) -> Result<Arc<dyn GitRepository>>;
async fn git_init(&self, abs_work_directory: &Path, fallback_branch_name: String)
-> Result<()>;
async fn git_clone(&self, repo_url: &str, abs_work_directory: &Path) -> Result<()>;
@@ -1149,8 +1149,8 @@ impl Fs for RealFs {
&self,
dotgit_path: &Path,
system_git_binary_path: Option<&Path>,
- ) -> Option<Arc<dyn GitRepository>> {
- Some(Arc::new(RealGitRepository::new(
+ ) -> Result<Arc<dyn GitRepository>> {
+ Ok(Arc::new(RealGitRepository::new(
dotgit_path,
self.bundled_git_binary_path.clone(),
system_git_binary_path.map(|path| path.to_path_buf()),
@@ -2866,9 +2866,7 @@ impl Fs for FakeFs {
&self,
abs_dot_git: &Path,
_system_git_binary: Option<&Path>,
- ) -> Option<Arc<dyn GitRepository>> {
- use util::ResultExt as _;
-
+ ) -> Result<Arc<dyn GitRepository>> {
self.with_git_state_and_paths(
abs_dot_git,
false,
@@ -2884,7 +2882,6 @@ impl Fs for FakeFs {
}) as _
},
)
- .log_err()
}
async fn git_init(
@@ -91,7 +91,7 @@ async fn get_messages_impl(git: &GitBinary, shas: &[Oid]) -> Result<Vec<String>>
anyhow::ensure!(
output.status.success(),
"'git show' failed with error {:?}",
- output.status
+ String::from_utf8_lossy(&output.stderr)
);
Ok(String::from_utf8_lossy(&output.stdout)
.trim()
@@ -1000,11 +1000,18 @@ impl RealGitRepository {
bundled_git_binary_path: Option<PathBuf>,
system_git_binary_path: Option<PathBuf>,
executor: BackgroundExecutor,
- ) -> Option<Self> {
- let any_git_binary_path = system_git_binary_path.clone().or(bundled_git_binary_path)?;
- let workdir_root = dotgit_path.parent()?;
- let repository = git2::Repository::open(workdir_root).log_err()?;
- Some(Self {
+ ) -> Result<Self> {
+ let any_git_binary_path = system_git_binary_path
+ .clone()
+ .or(bundled_git_binary_path)
+ .context("no git binary available")?;
+ log::info!(
+ "opening git repository at {dotgit_path:?} using git binary {any_git_binary_path:?}"
+ );
+ let workdir_root = dotgit_path.parent().context(".git has no parent")?;
+ let repository =
+ git2::Repository::open(workdir_root).context("creating libgit2 repository")?;
+ Ok(Self {
repository: Arc::new(Mutex::new(repository)),
system_git_binary_path,
any_git_binary_path,