diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 86bba441b018d71fe7048a51ed20ba22e6e0130f..af8519f0269b38bcde65bb03882ee98d54adc6b6 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -3084,6 +3084,15 @@ impl RepositorySnapshot { .cloned() } + pub fn new_pending_op(&self, git_status: pending_op::GitStatus) -> PendingOp { + let id = self.pending_ops_by_path.summary().item_summary.max_id + 1; + PendingOp { + id, + git_status, + job_status: pending_op::JobStatus::Started, + } + } + pub fn abs_path_to_repo_path(&self, abs_path: &Path) -> Option { Self::abs_path_to_repo_path_inner(&self.work_directory_abs_path, abs_path, self.path_style) } @@ -3823,25 +3832,14 @@ impl Repository { let mut edits = Vec::with_capacity(entries.len()); for entry in &entries { - let id = self - .snapshot - .pending_ops_by_path - .summary() - .item_summary - .max_id - + 1; - let op = PendingOp { - id, - git_status: pending_op::GitStatus::Staged, - job_status: pending_op::JobStatus::Started, - }; + let op = self.snapshot.new_pending_op(pending_op::GitStatus::Staged); let mut ops = self .snapshot .pending_ops_for_path(entry) .unwrap_or_else(|| PendingOps::new(entry)); ops.ops.push(op); edits.push(sum_tree::Edit::Insert(ops)); - ids.push((id, entry.clone())); + ids.push((op.id, entry.clone())); } self.snapshot.pending_ops_by_path.edit(edits, ()); @@ -3931,25 +3929,16 @@ impl Repository { let mut edits = Vec::with_capacity(entries.len()); for entry in &entries { - let id = self + let op = self .snapshot - .pending_ops_by_path - .summary() - .item_summary - .max_id - + 1; - let op = PendingOp { - id, - git_status: pending_op::GitStatus::Unstaged, - job_status: pending_op::JobStatus::Started, - }; + .new_pending_op(pending_op::GitStatus::Unstaged); let mut ops = self .snapshot .pending_ops_for_path(entry) .unwrap_or_else(|| PendingOps::new(entry)); ops.ops.push(op); edits.push(sum_tree::Edit::Insert(ops)); - ids.push((id, entry.clone())); + ids.push((op.id, entry.clone())); } self.snapshot.pending_ops_by_path.edit(edits, ()); diff --git a/crates/project/src/git_store/pending_op.rs b/crates/project/src/git_store/pending_op.rs index 4a3d7ed237f4da9f1daf221cf6c6253b1ef6b917..0b885b630ac15749c33bb1154ea3fa2abe057812 100644 --- a/crates/project/src/git_store/pending_op.rs +++ b/crates/project/src/git_store/pending_op.rs @@ -25,7 +25,7 @@ pub struct PendingOps { pub ops: Vec, } -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct PendingOp { pub id: PendingOpId, pub git_status: GitStatus,