From bd784238fa9d6cdf671f3ecb890287e4a4f8ca56 Mon Sep 17 00:00:00 2001 From: Anthony Eid Date: Mon, 6 Apr 2026 16:15:26 -0400 Subject: [PATCH] Remove stage_all_including_untracked method 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 --- 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(-) diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index 62e6522af98ae6508db355c699559d457056a7e1..30643bfd0b5b710e627e827294fc4076c177c48c 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/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 = 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); diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index f906274bd3f350c52cc5878d204c979e388f2737..3edc2aa60d634d33ffa1946324385102c22b7f35 100644 --- a/crates/git/src/repository.rs +++ b/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 = vec!["add".into(), "-A".into()]; - git_binary?.run(&args).await?; - Ok(()) - }) - .boxed() - } - fn push( &self, branch_name: String, diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index fa37c43b4f4090aa97ea86087559949eec7b912a..4ffda4971e1f9c25a6ef448f3631846ddb421e3a 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -6118,21 +6118,6 @@ impl Repository { }) } - pub fn stage_all_including_untracked(&mut self) -> oneshot::Receiver> { - 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> { let id = self.id; self.send_job(