From a5cc6af89fcf62fae36a724ddf3b629872efb8c1 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 1 Apr 2026 15:31:51 -0400 Subject: [PATCH] Expose new git operations through git_store::Repository - Add create_worktree_detached (detached HEAD worktree creation) - Add head_sha, update_ref, delete_ref, stage_all_including_untracked - Wire allow_empty through to the commit proto and local paths --- crates/project/src/git_store.rs | 86 ++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 6f838f02768a38d1c84935f5a7e7a303e682847d..06cde5c16adc5bef2e838e35129c35324143497d 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -2334,6 +2334,7 @@ impl GitStore { CommitOptions { amend: options.amend, signoff: options.signoff, + allow_empty: options.allow_empty, }, askpass, cx, @@ -5394,6 +5395,7 @@ impl Repository { options: Some(proto::commit::CommitOptions { amend: options.amend, signoff: options.signoff, + allow_empty: options.allow_empty, }), askpass_id, }) @@ -5887,7 +5889,9 @@ impl Repository { move |repo, _cx| async move { match repo { RepositoryState::Local(LocalRepositoryState { backend, .. }) => { - backend.create_worktree(branch_name, path, commit).await + backend + .create_worktree(Some(branch_name), path, commit) + .await } RepositoryState::Remote(RemoteRepositoryState { project_id, client }) => { client @@ -5907,6 +5911,86 @@ impl Repository { ) } + pub fn create_worktree_detached( + &mut self, + path: PathBuf, + commit: String, + ) -> oneshot::Receiver> { + self.send_job( + Some("git worktree add (detached)".into()), + move |repo, _cx| async move { + match repo { + RepositoryState::Local(LocalRepositoryState { backend, .. }) => { + backend.create_worktree(None, path, Some(commit)).await + } + RepositoryState::Remote(_) => { + anyhow::bail!( + "create_worktree_detached is not supported for remote repositories" + ) + } + } + }, + ) + } + + pub fn head_sha(&mut self) -> oneshot::Receiver>> { + self.send_job(None, move |repo, _cx| async move { + match repo { + RepositoryState::Local(LocalRepositoryState { backend, .. }) => { + Ok(backend.head_sha().await) + } + RepositoryState::Remote(_) => { + anyhow::bail!("head_sha is not supported for remote repositories") + } + } + }) + } + + pub fn update_ref( + &mut self, + ref_name: String, + commit: String, + ) -> oneshot::Receiver> { + self.send_job(None, move |repo, _cx| async move { + match repo { + RepositoryState::Local(LocalRepositoryState { backend, .. }) => { + backend.update_ref(ref_name, commit).await + } + RepositoryState::Remote(_) => { + anyhow::bail!("update_ref is not supported for remote repositories") + } + } + }) + } + + pub fn delete_ref(&mut self, ref_name: String) -> oneshot::Receiver> { + self.send_job(None, move |repo, _cx| async move { + match repo { + RepositoryState::Local(LocalRepositoryState { backend, .. }) => { + backend.delete_ref(ref_name).await + } + RepositoryState::Remote(_) => { + anyhow::bail!("delete_ref is not supported for remote repositories") + } + } + }) + } + + 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(