diff --git a/crates/gitbutler-branch/src/virtual.rs b/crates/gitbutler-branch/src/virtual.rs index 41cf8b296..754369607 100644 --- a/crates/gitbutler-branch/src/virtual.rs +++ b/crates/gitbutler-branch/src/virtual.rs @@ -1903,7 +1903,7 @@ pub fn write_tree_onto_tree( for (rel_path, hunks) in files { let rel_path = rel_path.borrow(); let hunks = hunks.borrow(); - let full_path = project_repository.path().join(rel_path); + let full_path = project_repository.project().worktree_path().join(rel_path); let is_submodule = full_path.is_dir() && hunks.len() == 1 @@ -1950,7 +1950,7 @@ pub fn write_tree_onto_tree( // if the link target is inside the project repository, make it relative let link_target = link_target - .strip_prefix(project_repository.path()) + .strip_prefix(project_repository.project().worktree_path()) .unwrap_or(&link_target); let blob_oid = git_repository.blob( diff --git a/crates/gitbutler-core/src/project_repository/repository.rs b/crates/gitbutler-core/src/project_repository/repository.rs index cea95ae1c..7d9929235 100644 --- a/crates/gitbutler-core/src/project_repository/repository.rs +++ b/crates/gitbutler-core/src/project_repository/repository.rs @@ -1,5 +1,4 @@ use std::{ - path, str::FromStr, sync::{atomic::AtomicUsize, Arc}, }; @@ -139,14 +138,9 @@ pub trait RepoActions { fn get_head(&self) -> Result; fn git_index_size(&self) -> Result; fn config(&self) -> super::Config; - fn path(&self) -> &path::Path; } impl RepoActions for ProjectRepo { - fn path(&self) -> &path::Path { - path::Path::new(&self.project.path) - } - fn config(&self) -> super::Config { super::Config::from(&self.git_repository) } @@ -493,7 +487,7 @@ impl RepoActions for ProjectRepo { // NOTE(qix-): work around a time-sensitive change that was necessary // NOTE(qix-): without having to refactor a large portion of the codebase. if self.project.preferred_key == AuthKey::SystemExecutable { - let path = self.path().to_path_buf(); + let path = self.project.worktree_path(); let remote = branch.remote().to_string(); return std::thread::spawn(move || { tokio::runtime::Runtime::new() @@ -589,7 +583,7 @@ impl RepoActions for ProjectRepo { // NOTE(qix-): work around a time-sensitive change that was necessary // NOTE(qix-): without having to refactor a large portion of the codebase. if self.project.preferred_key == AuthKey::SystemExecutable { - let path = self.path().to_path_buf(); + let path = self.project.worktree_path(); let remote = remote_name.to_string(); return std::thread::spawn(move || { tokio::runtime::Runtime::new() diff --git a/crates/gitbutler-core/src/projects/project.rs b/crates/gitbutler-core/src/projects/project.rs index 6fba7acea..782dd4bce 100644 --- a/crates/gitbutler-core/src/projects/project.rs +++ b/crates/gitbutler-core/src/projects/project.rs @@ -120,4 +120,8 @@ impl Project { pub fn snapshot_lines_threshold(&self) -> usize { self.snapshot_lines_threshold.unwrap_or(20) } + + pub fn worktree_path(&self) -> PathBuf { + self.path.clone() + } }