Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
git: Improve handling of unsafe repositories (#43693)
Dino1afe44c1b681
diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rsindex 5b505d4d7a0..2d716f8e519 100644--- a/crates/fs/src/fs.rs+++ b/crates/fs/src/fs.rs@@ -13,7 +13,6 @@ use gpui::BackgroundExecutor;use gpui::Global;use gpui::ReadGlobal as _;use gpui::SharedString;-use std::borrow::Cow;#[cfg(unix)]use std::ffi::CString;use util::command::new_command;@@ -287,7 +286,8 @@ pub trait Fs: Send + Sync {) -> Result<Arc<dyn GitRepository>>;async fn git_init(&self, abs_work_directory: &Path, fallback_branch_name: String)-> Result<()>;- async fn git_clone(&self, repo_url: &str, abs_work_directory: &Path) -> Result<()>;+ async fn git_clone(&self, abs_work_directory: &Path, repo_url: &str) -> Result<()>;+ async fn git_config(&self, abs_work_directory: &Path, args: Vec<String>) -> Result<String>;fn is_fake(&self) -> bool;async fn is_case_sensitive(&self) -> bool;fn subscribe_to_jobs(&self) -> JobEventReceiver;@@ -1283,19 +1283,19 @@ impl Fs for RealFs {abs_work_directory_path: &Path,fallback_branch_name: String,) -> Result<()> {- let config = new_command("git")+ let result = new_command("git").current_dir(abs_work_directory_path).args(&["config", "--global", "--get", "init.defaultBranch"]).output()- .await?;-- let branch_name;+ .await;- if config.status.success() && !config.stdout.is_empty() {- branch_name = String::from_utf8_lossy(&config.stdout);- } else {- branch_name = Cow::Borrowed(fallback_branch_name.as_str());- }+ // In case the `git config` command fails, which would be the case if+ // the user doesn't have an `init.defaultBranch` value set, we'll just+ // default to the provided `fallback_branch_name`.+ let branch_name = match result {+ Ok(output) if !output.stdout.is_empty() => String::from_utf8(output.stdout)?,+ _ => fallback_branch_name,+ };new_command("git").current_dir(abs_work_directory_path)@@ -1307,7 +1307,7 @@ impl Fs for RealFs {Ok(())}- async fn git_clone(&self, repo_url: &str, abs_work_directory: &Path) -> Result<()> {+ async fn git_clone(&self, abs_work_directory: &Path, repo_url: &str) -> Result<()> {let job_id = self.next_job_id.fetch_add(1, Ordering::SeqCst);let job_info = JobInfo {id: job_id,@@ -1333,6 +1333,24 @@ impl Fs for RealFs {Ok(())}+ /// Runs `git config` with the given arguments.+ /// Will return `Ok` if the commands exit status is `0`, with the stdout+ /// contents. Otherwise returns `Err` with the stderr contents.+ async fn git_config(&self, abs_work_directory: &Path, args: Vec<String>) -> Result<String> {+ let output = new_command("git")+ .current_dir(abs_work_directory)+ .args([String::from("config")].into_iter().chain(args))+ .output()+ .await?;++ if !output.status.success() {+ let err = String::from_utf8(output.stderr)?;+ anyhow::bail!(err);+ }++ String::from_utf8(output.stdout).map_err(Into::into)+ }+fn is_fake(&self) -> bool {false}@@ -3245,10 +3263,14 @@ impl Fs for FakeFs {self.create_dir(&abs_work_directory_path.join(".git")).await}- async fn git_clone(&self, _repo_url: &str, _abs_work_directory: &Path) -> Result<()> {+ async fn git_clone(&self, _abs_work_directory: &Path, _repo_url: &str) -> Result<()> {anyhow::bail!("Git clone is not supported in fake Fs")}+ async fn git_config(&self, _abs_work_directory: &Path, _args: Vec<String>) -> Result<String> {+ anyhow::bail!("Git config is not supported in fake Fs")+ }+fn is_fake(&self) -> bool {true}diff --git a/crates/git_ui/src/clone.rs b/crates/git_ui/src/clone.rsindex b3b8a9ed6fb..61b6275eb91 100644--- a/crates/git_ui/src/clone.rs+++ b/crates/git_ui/src/clone.rs@@ -39,7 +39,7 @@ pub fn clone_and_open(let destination_dir = destination_dir.clone();let repo_url = repo_url.clone();cx.spawn(async move |_workspace, _cx| {- fs.git_clone(&repo_url, destination_dir.as_path()).await+ fs.git_clone(destination_dir.as_path(), &repo_url).await})}).ok()?;diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rsindex ebb2e3c1c26..1e53c1cf53e 100644--- a/crates/git_ui/src/git_panel.rs+++ b/crates/git_ui/src/git_panel.rs@@ -22,6 +22,7 @@ use editor::{use editor::{EditorStyle, RewrapOptions};use file_icons::FileIcons;use futures::StreamExt as _;+use futures::channel::oneshot::Canceled;use git::commit::ParsedCommitMessage;use git::repository::{Branch, CommitDetails, CommitOptions, CommitSummary, DiffType, FetchOptions, GitCommitTemplate,@@ -51,6 +52,7 @@ use menu;use multi_buffer::ExcerptBoundaryInfo;use notifications::status_toast::StatusToast;use panel::{PanelHeader, panel_button, panel_filled_button, panel_icon_button};+use project::git_store::GitAccess;use project::{Fs, Project, ProjectPath,git_store::{GitStoreEvent, Repository, RepositoryEvent, RepositoryId, pending_op},@@ -656,6 +658,7 @@ pub struct GitPanel {stash_entries: GitStash,_settings_subscription: Subscription,+ git_access: GitAccess,}#[derive(Clone, Debug, PartialEq, Eq)]@@ -786,6 +789,7 @@ impl GitPanel {)| GitStoreEvent::RepositoryAdded| GitStoreEvent::RepositoryRemoved(_)+ | GitStoreEvent::GlobalConfigurationUpdated| GitStoreEvent::ActiveRepositoryChanged(_) => {this.schedule_update(window, cx);}@@ -843,6 +847,7 @@ impl GitPanel {bulk_staging: None,stash_entries: Default::default(),_settings_subscription,+ git_access: GitAccess::Yes,};this.schedule_update(window, cx);@@ -1744,11 +1749,18 @@ impl GitPanel {// 3. finally, if there is no info about this `entry` in the repo, we fall back to whatever status is encoded// in `entry` arg.repo.pending_ops_for_path(&entry.repo_path)- .map(|ops| {+ .and_then(|ops| {+ // In case the last operation in the list of pending operations+ // failed, we can't assume the stage status for this entry and+ // need to fallback to the actual state in the repo.+ if ops.last_op_errored() {+ return None;+ }+if ops.staging() || ops.staged() {- StageStatus::Staged+ Some(StageStatus::Staged)} else {- StageStatus::Unstaged+ Some(StageStatus::Unstaged)}}).or_else(|| {@@ -1950,6 +1962,7 @@ impl GitPanel {this.update(cx, |this, cx| {if let Err(err) = result {this.show_error_toast(if stage { "add" } else { "reset" }, err, cx);+ this.update_counts(active_repository.read(cx));}cx.notify();})@@ -3110,6 +3123,37 @@ impl GitPanel {.detach_and_log_err(cx);}+ /// Updates git's configuration, adding the directory of the current+ /// worktree to the `safe.directory` config, ensuring that, even if the user+ /// that's running the application is not the owner of `.git/`, it can still+ /// read the repository's contents.+ fn add_safe_directory(&mut self, window: &mut Window, cx: &mut Context<Self>) {+ let Some(active_repository) = &self.active_repository else {+ return;+ };++ let path = active_repository.update(cx, |repository, _cx| {+ repository.snapshot().work_directory_abs_path+ });++ if let Some(path_str) = path.to_str() {+ let path_arg = String::from(path_str);+ let args = vec![+ String::from("--global"),+ String::from("--add"),+ String::from("safe.directory"),+ path_arg,+ ];++ cx.spawn_in(window, async move |git_panel, cx| {+ git_panel.update(cx, |git_panel, cx| {+ git_panel.project.read(cx).git_config(path, args, cx)+ })+ })+ .detach();+ }+ }+pub fn create_pull_request(&self, window: &mut Window, cx: &mut Context<Self>) {let result = (|| -> anyhow::Result<()> {let repo = self@@ -3507,11 +3551,37 @@ impl GitPanel {self.tracked_staged_count = 0;self.entry_count = 0;self.max_width_item_index = None;+ self.git_access = GitAccess::Yes;let sort_by_path = GitPanelSettings::get_global(cx).sort_by_path;let is_tree_view = matches!(self.view_mode, GitPanelViewMode::Tree(_));let group_by_status = is_tree_view || !sort_by_path;+ if let Some(active_repo) = self.active_repository.as_ref() {+ let access = active_repo.update(cx, |active_repo, cx| active_repo.access(cx));++ cx.spawn_in(window, async move |git_panel, cx| {+ // When the user does not own the `.git` folder, the+ // `GitStore.spawn_local_git_worker` will fail to create the+ // receiver for Git jobs, so this access check will be+ // cancelled.+ //+ // We assume `GitAccess::No` on cancellation. I believe this is+ // imprecise, other failures could also cause cancellation, but+ // the consequence is just showing the "unsafe repo" UI, which+ // seems acceptable for this edge case.+ let access = match access.await {+ Ok(access) => access,+ Err(Canceled) => GitAccess::No,+ };++ git_panel.update(cx, |this, _cx| {+ this.git_access = access;+ })+ })+ .detach_and_log_err(cx);+ }+let mut changed_entries = Vec::new();let mut new_entries = Vec::new();let mut conflict_entries = Vec::new();@@ -4205,6 +4275,10 @@ impl GitPanel {window: &mut Window,cx: &mut Context<Self>,) -> Option<impl IntoElement> {+ if matches!(self.git_access, GitAccess::No) {+ return None;+ }+self.active_repository.as_ref()?;let (text, action, stage, tooltip) =@@ -4659,17 +4733,10 @@ impl GitPanel {}fn render_empty_state(&self, cx: &mut Context<Self>) -> impl IntoElement {- let has_repo = self.active_repository.is_some();- let has_no_repo = self.active_repository.is_none();- let worktree_count = self.project.read(cx).visible_worktrees(cx).count();-- let should_show_branch_diff =- has_repo && self.changes_count == 0 && !self.is_on_main_branch(cx);-- let label = if has_repo {- "No changes to commit"- } else {- "No Git repositories"+ let children = match (self.git_access, &self.active_repository) {+ (GitAccess::No, Some(repository)) => self.render_unsafe_repo_ui(repository, cx),+ (_, None) => self.render_uninitialized_ui(cx),+ (_, Some(_)) => self.render_no_changes_ui(cx),};v_flex()@@ -4677,40 +4744,110 @@ impl GitPanel {.flex_1().items_center().justify_center()- .child(Label::new(label).size(LabelSize::Small).color(Color::Muted))- .when(has_no_repo && worktree_count > 0, |this| {- this.child(- panel_filled_button("Initialize Repository")- .tooltip(Tooltip::for_action_title_in(- "git init",- &git::Init,- &self.focus_handle,- ))- .on_click(move |_, _, cx| {- cx.defer(move |cx| {- cx.dispatch_action(&git::Init);- })- }),- )- })- .when(should_show_branch_diff, |this| {- this.child(- panel_filled_button("View Branch Diff")- .tooltip(move |_, cx| {- Tooltip::with_meta(- "Branch Diff",- Some(&BranchDiff),- "Show diff between working directory and default branch",- cx,- )+ .text_color(Color::Placeholder.color(cx))+ .children(children)+ }++ fn render_no_changes_ui(&self, cx: &Context<Self>) -> Vec<AnyElement> {+ let mut elements: Vec<AnyElement> = vec!["No changes to commit".into_any_element()];++ if self.changes_count == 0 && !self.is_on_main_branch(cx) {+ elements.push(+ panel_filled_button("View Branch Diff")+ .tooltip(move |_, cx| {+ Tooltip::with_meta(+ "Branch Diff",+ Some(&BranchDiff),+ "Show diff between working directory and default branch",+ cx,+ )+ })+ .on_click(move |_, _, cx| {+ cx.defer(move |cx| {+ cx.dispatch_action(&BranchDiff);})- .on_click(move |_, _, cx| {- cx.defer(move |cx| {- cx.dispatch_action(&BranchDiff);- })- }),+ })+ .into_any_element(),+ );+ }++ elements+ }++ fn render_unsafe_repo_ui(+ &self,+ active_repository: &Entity<Repository>,+ cx: &mut Context<Self>,+ ) -> Vec<AnyElement> {+ let directory = active_repository.update(cx, |repository, _cx| {+ repository.snapshot().work_directory_abs_path+ });++ let message = format!(+ "Detected dubious ownership in repository at {}. \+ This happens when the .git/ directory is not owned by the current user. \+ If you want to learn more about safe directories, visit git's documentation.",+ directory.display()+ );++ vec![+ div()+ .self_stretch()+ .px_4()+ .text_center()+ .child(Label::new(message).color(Color::Muted))+ .into_any_element(),+ self.render_unsafe_repo_buttons(directory, cx)+ .into_any_element(),+ ]+ }++ fn render_unsafe_repo_buttons(&self, directory: Arc<Path>, cx: &mut Context<Self>) -> Div {+ h_flex()+ .max_w_full()+ .gap_2()+ .justify_center()+ .child(+ panel_filled_button("Trust Directory")+ .end_icon(Icon::new(IconName::Check).size(IconSize::Small))+ .tooltip(Tooltip::text(+ format!("git config --global --add safe.directory {}", directory.display())+ ))+ .on_click(+ cx.listener(|this, _, window, cx| {+ this.add_safe_directory(window, cx);+ }))- })+ )+ .child(+ panel_filled_button("Learn More")+ .end_icon(Icon::new(IconName::Link).size(IconSize::Small))+ .tooltip(Tooltip::text("Open https://git-scm.com/docs/git-config#Documentation/git-config.txt-safedirectory in your default browser"))+ .on_click(move |_, _, cx| cx.open_url("https://git-scm.com/docs/git-config#Documentation/git-config.txt-safedirectory"))+ )+ }++ fn render_uninitialized_ui(&self, cx: &mut Context<Self>) -> Vec<AnyElement> {+ let worktree_count = self.project.read(cx).visible_worktrees(cx).count();+ if worktree_count > 0 && self.active_repository.is_none() {+ vec![+ "No Git Repositories".into_any_element(),+ panel_filled_button("Initialize Repository")+ .tooltip(Tooltip::for_action_title_in(+ "git init",+ &git::Init,+ &self.focus_handle,+ ))+ .on_click(move |_, _, cx| {+ cx.defer(move |cx| {+ cx.dispatch_action(&git::Init);+ })+ })+ .into_any_element(),+ ]+ } else {+ vec![]+ }}fn is_on_main_branch(&self, cx: &Context<Self>) -> bool {@@ -4741,7 +4878,7 @@ impl GitPanel {let is_staging_or_staged = repo.pending_ops_for_path(&repo_path)- .map(|ops| ops.staging() || ops.staged())+ .map(|ops| !ops.last_op_errored() && (ops.staging() || ops.staged())).or_else(|| {repo.status_for_path(&repo_path).and_then(|status| status.status.staging().as_bool())diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rsindex 71eaca61cfd..a6d963bd111 100644--- a/crates/project/src/git_store.rs+++ b/crates/project/src/git_store.rs@@ -54,6 +54,7 @@ use language::{proto::{deserialize_version, serialize_version},};use parking_lot::Mutex;+use paths::{config_dir, home_dir};use pending_op::{PendingOp, PendingOpId, PendingOps, PendingOpsSummary};use postage::stream::Stream as _;use rpc::{@@ -163,12 +164,29 @@ enum DiffKind {SinceOid(Option<git::Oid>),}+#[derive(Debug, Default, Clone, Copy)]+pub enum GitAccess {+ /// Either:+ /// - the user owns `.git`+ /// - the user doesn't own `.git`, but has both of:+ /// - OS-level read permissions+ /// - the directory is marked as safe (git config safe.directory)+ #[default]+ Yes,++ /// The user is not the owner of `.git`, and one of the following is true:+ /// - the directory is not marked as safe (git config safe.directory)+ /// - the user does not have OS-level read permissions to `.git`+ No,+}+enum GitStoreState {Local {next_repository_id: Arc<AtomicU64>,downstream: Option<LocalDownstreamState>,project_environment: Entity<ProjectEnvironment>,fs: Arc<dyn Fs>,+ _fs_watches: Box<[Task<()>]>,},Remote {upstream_client: AnyProtoClient,@@ -362,6 +380,14 @@ pub struct Repository {initial_graph_data: HashMap<(LogSource, LogOrder), InitialGitGraphData>,commit_data_handler: CommitDataHandlerState,commit_data: HashMap<Oid, CommitDataState>,+ refetch_repo_state: Arc<+ dyn Fn(+ &mut Context<Self>,+ ) -> (+ mpsc::UnboundedSender<GitJob>,+ Shared<Task<Result<RepositoryState, String>>>,+ ),+ >,}impl std::ops::Deref for Repository {@@ -465,6 +491,7 @@ pub enum GitStoreEvent {IndexWriteError(anyhow::Error),JobsUpdated,ConflictsUpdated,+ GlobalConfigurationUpdated,}impl EventEmitter<RepositoryEvent> for Repository {}@@ -492,6 +519,43 @@ impl GitStore {fs: Arc<dyn Fs>,cx: &mut Context<Self>,) -> Self {+ let _fs_watches = if fs.is_fake() {+ Box::new([])+ } else {+ [+ config_dir().join("git/config"),+ home_dir().join(".gitconfig"),+ ]+ .into_iter()+ .map(|path| {+ let fs = fs.clone();++ cx.spawn(async move |this, cx| {+ let watcher = fs.watch(&path, Duration::from_millis(100));+ let (mut watcher, _) = watcher.await;+ while let Some(_) = watcher.next().await {+ let Ok(_) = this.update(cx, |this, cx| {+ for repo in this.repositories.values() {+ repo.update(cx, |this, cx| {+ if this.job_sender.is_closed() {+ let (job_sender, state) = (this.refetch_repo_state)(cx);+ this.repository_state = state;+ this.job_sender = job_sender;+ this.schedule_scan(None, cx);+ }+ })+ }+ cx.emit(GitStoreEvent::GlobalConfigurationUpdated);+ }) else {+ return;+ };+ }+ })+ })+ .collect::<Vec<_>>()+ .into_boxed_slice()+ };+Self::new(worktree_store.clone(),buffer_store,@@ -499,6 +563,7 @@ impl GitStore {next_repository_id: Arc::new(AtomicU64::new(1)),downstream: None,project_environment: environment,+ _fs_watches,fs,},cx,@@ -1386,6 +1451,7 @@ impl GitStore {downstream,next_repository_id,fs,+ ..} = &self.stateelse {return;@@ -1931,7 +1997,7 @@ impl GitStore {GitStoreState::Local { fs, .. } => {let fs = fs.clone();cx.background_executor()- .spawn(async move { fs.git_clone(&repo, &path).await })+ .spawn(async move { fs.git_clone(&path, &repo).await })}GitStoreState::Remote {upstream_client,@@ -1961,6 +2027,31 @@ impl GitStore {}}+ pub fn git_config(&self, path: Arc<Path>, args: Vec<String>, cx: &App) -> Task<Result<String>> {+ match &self.state {+ GitStoreState::Local { fs, .. } => {+ let fs = fs.clone();+ cx.background_executor()+ .spawn(async move { fs.git_config(&path, args).await })+ }+ GitStoreState::Remote {+ upstream_client, ..+ } => {+ // Prevent running git config commands for collab.+ if upstream_client.is_via_collab() {+ return Task::ready(Err(anyhow!(+ "Git Config isn't support for project guests"+ )));+ }++ // TODO: Implement this for remote repositories.+ Task::ready(Err(anyhow!(+ "Git Config isn't yet supported for remote projects"+ )))+ }+ }+ }+async fn handle_update_repository(this: Entity<Self>,envelope: TypedEnvelope<proto::UpdateRepository>,@@ -4189,27 +4280,38 @@ impl Repository {Some(original_repo_abs_path),PathStyle::local(),);- let state = cx- .spawn(async move |_, cx| {- LocalRepositoryState::new(- work_directory_abs_path,- dot_git_abs_path,- project_environment,- fs,- is_trusted,- cx,- )- .await- .map_err(|err| err.to_string())- })- .shared();- let job_sender = Repository::spawn_local_git_worker(state.clone(), cx);- let state = cx- .spawn(async move |_, _| {- let state = state.await?;- Ok(RepositoryState::Local(state))- })- .shared();+ let refetch_repo_state = Arc::new(move |cx: &mut Context<Self>| {+ let work_directory_abs_path = work_directory_abs_path.clone();+ let dot_git_abs_path = dot_git_abs_path.clone();+ let project_environment = project_environment.clone();+ let fs = fs.clone();++ let state = cx+ .spawn(async move |_, cx| {+ LocalRepositoryState::new(+ work_directory_abs_path,+ dot_git_abs_path,+ project_environment,+ fs,+ is_trusted,+ cx,+ )+ .await+ .map_err(|err| err.to_string())+ })+ .shared();+ let job_sender = Repository::spawn_local_git_worker(state.clone(), cx);+ let state = cx+ .spawn(async move |_, _| {+ let state = state.await?;+ Ok(RepositoryState::Local(state))+ })+ .shared();++ (job_sender, state)+ });++ let (job_sender, state) = (refetch_repo_state)(cx);// todo(git_graph_remote): Make this subscription on both remote/local repocx.subscribe_self(move |this, event: &RepositoryEvent, _| match event {@@ -4244,6 +4346,7 @@ impl Repository {initial_graph_data: Default::default(),commit_data: Default::default(),commit_data_handler: CommitDataHandlerState::Closed,+ refetch_repo_state,}}@@ -4263,9 +4366,18 @@ impl Repository {original_repo_abs_path,path_style,);- let repository_state = RemoteRepositoryState { project_id, client };- let job_sender = Self::spawn_remote_git_worker(repository_state.clone(), cx);- let repository_state = Task::ready(Ok(RepositoryState::Remote(repository_state))).shared();+ let refetch_repo_state = Arc::new(move |cx: &mut Context<Self>| {+ let repository_state = RemoteRepositoryState {+ project_id,+ client: client.clone(),+ };+ let job_sender = Self::spawn_remote_git_worker(repository_state.clone(), cx);+ let repository_state =+ Task::ready(Ok(RepositoryState::Remote(repository_state))).shared();+ (job_sender, repository_state)+ });++ let (job_sender, repository_state) = (refetch_repo_state)(cx);Self {this: cx.weak_entity(),snapshot,@@ -4282,6 +4394,7 @@ impl Repository {initial_graph_data: Default::default(),commit_data: Default::default(),commit_data_handler: CommitDataHandlerState::Closed,+ refetch_repo_state,}}@@ -5545,8 +5658,9 @@ impl Repository {snapshot.status().filter_map(|entry| {- if let Some(ops) =- pending_ops.get(&PathKey(entry.repo_path.as_ref().clone()), ())+ if let Some(ops) = pending_ops+ .get(&PathKey(entry.repo_path.as_ref().clone()), ())+ .filter(|ops| !ops.last_op_errored()){if ops.staging() || ops.staged() {None@@ -5578,8 +5692,9 @@ impl Repository {snapshot.status().filter_map(|entry| {- if let Some(ops) =- pending_ops.get(&PathKey(entry.repo_path.as_ref().clone()), ())+ if let Some(ops) = pending_ops+ .get(&PathKey(entry.repo_path.as_ref().clone()), ())+ .filter(|ops| !ops.last_op_errored()){if !ops.staging() && !ops.staged() {None@@ -7588,6 +7703,23 @@ impl Repository {self.pending_ops.edit(edits, ());ids}++ pub fn access(&mut self, _cx: &App) -> oneshot::Receiver<GitAccess> {+ self.send_job(None, move |git_repo, _cx| async move {+ match git_repo {+ // TODO: Correctly handle remote repositories, where the user+ // that's running the Zed remote may not own the `.git/`+ // directory. For now we just return `GitAccess::Yes` so that+ // remoting continues working as expected.+ RepositoryState::Remote(..) => GitAccess::Yes,+ RepositoryState::Local(state) => match state.backend.status(&[]).await {+ Ok(_) => GitAccess::Yes,+ Err(_) => GitAccess::No,+ },+ }+ })+ }+pub fn default_remote_url(&self) -> Option<String> {self.remote_upstream_url.clone()diff --git a/crates/project/src/git_store/pending_op.rs b/crates/project/src/git_store/pending_op.rsindex 1991eed4078..269e17a4d4d 100644--- a/crates/project/src/git_store/pending_op.rs+++ b/crates/project/src/git_store/pending_op.rs@@ -130,6 +130,12 @@ impl PendingOps {}false}++ /// Checks whether the last operation in the pending operations resulted in+ /// an error.+ pub fn last_op_errored(&self) -> bool {+ self.ops.last().is_some_and(PendingOp::error)+ }}impl PendingOp {diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex c0b39c33dd7..af15ab44517 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -6036,6 +6036,10 @@ impl Project {.git_init(path, fallback_branch_name, cx)}+ pub fn git_config(&self, path: Arc<Path>, args: Vec<String>, cx: &App) -> Task<Result<String>> {+ self.git_store.read(cx).git_config(path, args, cx)+ }+pub fn buffer_store(&self) -> &Entity<BufferStore> {&self.buffer_store}