Hold repo lock while writing index text
Co-authored-by: João Marcos <marcospb19@hotmail.com>
This commit is contained in:
committed by
João Marcos
parent
731618aada
commit
facfae18a0
@@ -835,12 +835,12 @@ impl BufferDiff {
|
||||
|
||||
pub fn start_pending_op(&mut self) {
|
||||
self.pending_ops += 1;
|
||||
dbg!(("start", self.pending_ops));
|
||||
dbg!("start_pending_op", self.pending_ops);
|
||||
}
|
||||
|
||||
pub fn end_pending_op(&mut self, result: &Option<anyhow::Result<()>>, cx: &mut Context<Self>) {
|
||||
self.pending_ops = self.pending_ops.saturating_sub(1);
|
||||
dbg!("end", self.pending_ops);
|
||||
dbg!("end_pending_op", self.pending_ops);
|
||||
if let Some(Err(_)) = result {
|
||||
if let Some(changed_range) = self.clear_pending_hunks() {
|
||||
cx.emit(BufferDiffEvent::DiffChanged {
|
||||
|
||||
@@ -427,7 +427,11 @@ impl GitRepository for RealGitRepository {
|
||||
content: Option<String>,
|
||||
env: &HashMap<String, String>,
|
||||
) -> anyhow::Result<()> {
|
||||
let working_directory = self.working_directory()?;
|
||||
let repo = self.repository.lock();
|
||||
let working_directory = repo
|
||||
.workdir()
|
||||
.context("failed to read git work directory")
|
||||
.map(Path::to_path_buf)?;
|
||||
if let Some(content) = content {
|
||||
let mut child = new_std_command(&self.git_binary_path)
|
||||
.current_dir(&working_directory)
|
||||
|
||||
@@ -143,7 +143,7 @@ impl BufferDiffState {
|
||||
Some(rx)
|
||||
}
|
||||
|
||||
pub fn diff_bases_changed(
|
||||
fn diff_bases_changed(
|
||||
&mut self,
|
||||
buffer: text::BufferSnapshot,
|
||||
diff_bases_change: DiffBasesChange,
|
||||
@@ -834,7 +834,6 @@ impl LocalBufferStore {
|
||||
}
|
||||
|
||||
cx.spawn(move |this, mut cx| async move {
|
||||
git_store.wait_for_pending_index_writes().await;
|
||||
let snapshot =
|
||||
worktree_handle.update(&mut cx, |tree, _| tree.as_local().unwrap().snapshot())?;
|
||||
let diff_bases_changes_by_buffer = cx
|
||||
@@ -844,11 +843,13 @@ impl LocalBufferStore {
|
||||
.filter_map(|(buffer, path, current_index_text, current_head_text)| {
|
||||
let local_repo = snapshot.local_repo_for_path(&path)?;
|
||||
let relative_path = local_repo.relativize(&path).ok()?;
|
||||
dbg!("start loading index text {:?}", &relative_path);
|
||||
let index_text = if current_index_text.is_some() {
|
||||
local_repo.repo().load_index_text(&relative_path)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
dbg!("start loading head text {:?}", &relative_path);
|
||||
let head_text = if current_head_text.is_some() {
|
||||
local_repo.repo().load_committed_text(&relative_path)
|
||||
} else {
|
||||
|
||||
@@ -1651,7 +1651,12 @@ impl Repository {
|
||||
Some(GitJobKey::WriteIndex(path.clone())),
|
||||
|git_repo| async move {
|
||||
match git_repo {
|
||||
GitRepo::Local(repo) => repo.set_index_text(&path, content, &env.await),
|
||||
GitRepo::Local(repo) => {
|
||||
dbg!("set_index_text >>>");
|
||||
let result = repo.set_index_text(&path, content, &env.await);
|
||||
dbg!("set_index_text <<<");
|
||||
result
|
||||
}
|
||||
GitRepo::Remote {
|
||||
project_id,
|
||||
client,
|
||||
|
||||
Reference in New Issue
Block a user