aboutsummaryrefslogtreecommitdiff
path: root/src/workspace/git/discovery.rs
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-07-25 04:26:55 +0300
committerGitHub <noreply@github.com>2026-07-25 04:26:55 +0300
commitd4e0dd3d903c50d2edb8c3cec71952a83989b310 (patch)
treec90ec43a08fab1fc79e1d6db865c723877a051af /src/workspace/git/discovery.rs
parentb33e5f973fc89381aa4ac72b3a31fa087ec66e23 (diff)
perf: eliminate repeated workspace git discovery (#1842)
* perf: eliminate repeated workspace git discovery refs #1838 * fix: keep workspace labels current without extra redraws refs #1838 * fix: retain discovered workspace git metadata refs #1838
Diffstat (limited to 'src/workspace/git/discovery.rs')
-rw-r--r--src/workspace/git/discovery.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/workspace/git/discovery.rs b/src/workspace/git/discovery.rs
index 4edfcbc2..9e1be74d 100644
--- a/src/workspace/git/discovery.rs
+++ b/src/workspace/git/discovery.rs
@@ -25,6 +25,10 @@ pub fn derive_label_from_cwd(cwd: &Path) -> String {
}
}
+ fallback_label_from_cwd(cwd)
+}
+
+pub fn fallback_label_from_cwd(cwd: &Path) -> String {
if let Ok(home) = std::env::var("HOME") {
let home = Path::new(&home);
if cwd == home {
@@ -56,9 +60,11 @@ pub fn git_worktree_info(cwd: &Path) -> Option<GitWorktreeInfo> {
}
pub fn git_space_metadata(cwd: &Path) -> Option<GitSpaceMetadata> {
- git_repo_root(cwd)?;
-
let info = git_worktree_info(cwd)?;
+ Some(git_space_metadata_from_info(&info))
+}
+
+pub(super) fn git_space_metadata_from_info(info: &GitWorktreeInfo) -> GitSpaceMetadata {
let key = canonicalize_best_effort_path(&info.git_common_dir)
.display()
.to_string();
@@ -80,13 +86,13 @@ pub fn git_space_metadata(cwd: &Path) -> Option<GitSpaceMetadata> {
.and_then(|name| name.to_str())
.unwrap_or("repo")
.to_string();
- Some(GitSpaceMetadata {
+ GitSpaceMetadata {
key,
checkout_key,
label,
- repo_root: info.repo_root,
+ repo_root: info.repo_root.clone(),
is_linked_worktree: info.is_linked_worktree,
- })
+ }
}
pub(super) fn canonicalize_best_effort_path(path: &Path) -> PathBuf {