Remove stage_all_including_untracked method

Anthony Eid created

GitStore::stage_all already does everything this method does and updates
pending_ops as well. So I'm removing this method to avoid a potential
foot gun in our codebase

Change summary

crates/fs/src/fake_git_repo.rs  | 35 -----------------------------------
crates/git/src/repository.rs    | 13 -------------
crates/project/src/git_store.rs | 15 ---------------
3 files changed, 63 deletions(-)

Detailed changes

crates/fs/src/fake_git_repo.rs 🔗

@@ -1306,41 +1306,6 @@ impl GitRepository for FakeGitRepository {
         })
     }
 
-    fn stage_all_including_untracked(&self) -> BoxFuture<'_, Result<()>> {
-        let workdir_path = self.dot_git_path.parent().unwrap();
-        let git_files: Vec<(RepoPath, String)> = self
-            .fs
-            .files()
-            .iter()
-            .filter_map(|path| {
-                let repo_path = path.strip_prefix(workdir_path).ok()?;
-                if repo_path.starts_with(".git") {
-                    return None;
-                }
-                let content = self
-                    .fs
-                    .read_file_sync(path)
-                    .ok()
-                    .and_then(|bytes| String::from_utf8(bytes).ok())?;
-                let rel_path = RelPath::new(repo_path, PathStyle::local()).ok()?;
-                Some((RepoPath::from_rel_path(&rel_path), content))
-            })
-            .collect();
-
-        self.with_state_async(true, move |state| {
-            // Stage all filesystem contents, mirroring `git add -A`.
-            let fs_paths: HashSet<RepoPath> = git_files.iter().map(|(p, _)| p.clone()).collect();
-            for (path, content) in git_files {
-                state.index_contents.insert(path, content);
-            }
-            // Remove index entries for files that no longer exist on disk.
-            state
-                .index_contents
-                .retain(|path, _| fs_paths.contains(path));
-            Ok(())
-        })
-    }
-
     fn set_trusted(&self, trusted: bool) {
         self.is_trusted
             .store(trusted, std::sync::atomic::Ordering::Release);

crates/git/src/repository.rs 🔗

@@ -921,8 +921,6 @@ pub trait GitRepository: Send + Sync {
 
     fn delete_ref(&self, ref_name: String) -> BoxFuture<'_, Result<()>>;
 
-    fn stage_all_including_untracked(&self) -> BoxFuture<'_, Result<()>>;
-
     fn set_trusted(&self, trusted: bool);
     fn is_trusted(&self) -> bool;
 }
@@ -2210,17 +2208,6 @@ impl GitRepository for RealGitRepository {
             .boxed()
     }
 
-    fn stage_all_including_untracked(&self) -> BoxFuture<'_, Result<()>> {
-        let git_binary = self.git_binary();
-        self.executor
-            .spawn(async move {
-                let args: Vec<OsString> = vec!["add".into(), "-A".into()];
-                git_binary?.run(&args).await?;
-                Ok(())
-            })
-            .boxed()
-    }
-
     fn push(
         &self,
         branch_name: String,

crates/project/src/git_store.rs 🔗

@@ -6118,21 +6118,6 @@ impl Repository {
         })
     }
 
-    pub fn stage_all_including_untracked(&mut self) -> oneshot::Receiver<Result<()>> {
-        self.send_job(None, move |repo, _cx| async move {
-            match repo {
-                RepositoryState::Local(LocalRepositoryState { backend, .. }) => {
-                    backend.stage_all_including_untracked().await
-                }
-                RepositoryState::Remote(_) => {
-                    anyhow::bail!(
-                        "stage_all_including_untracked is not supported for remote repositories"
-                    )
-                }
-            }
-        })
-    }
-
     pub fn remove_worktree(&mut self, path: PathBuf, force: bool) -> oneshot::Receiver<Result<()>> {
         let id = self.id;
         self.send_job(