Fix git staging in a subfolder (#37860)

localcc created

Closes #37418 

Ideal fix for this would be #37855 but that is a large refactor so
implementing this as a workaround.

Release Notes:

- N/A

Change summary

crates/worktree/src/worktree.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

Detailed changes

crates/worktree/src/worktree.rs 🔗

@@ -4777,8 +4777,10 @@ impl BackgroundScanner {
                     .git_repositories
                     .iter()
                     .find_map(|(_, repo)| {
-                        if repo.common_dir_abs_path.as_ref() == &dot_git_dir
-                            || repo.repository_dir_abs_path.as_ref() == &dot_git_dir
+                        let dot_git_dir = SanitizedPath::new(&dot_git_dir);
+                        if SanitizedPath::new(repo.common_dir_abs_path.as_ref()) == dot_git_dir
+                            || SanitizedPath::new(repo.repository_dir_abs_path.as_ref())
+                                == dot_git_dir
                         {
                             Some(repo.clone())
                         } else {