Enable merge conflict parsing for currently-unmerged files (#31549)

Previously, we only enabled merge conflict parsing for files that were
unmerged at the last time a change was detected to the repo's merge
heads. Now we enable the parsing for these files *and* any files that
are currently unmerged.

The old strategy meant that conflicts produced via `git stash pop` would
not be parsed.

Release Notes:

- Fixed parsing of merge conflicts when the conflict was produced by a
`git stash pop`
This commit is contained in:
Max Brunsfeld 2025-05-27 13:34:39 -07:00 committed by GitHub
parent f54c057001
commit 697c2ba71f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 124 additions and 15 deletions

View file

@ -778,11 +778,7 @@ impl GitStore {
let is_unmerged = self
.repository_and_path_for_buffer_id(buffer_id, cx)
.map_or(false, |(repo, path)| {
repo.read(cx)
.snapshot
.merge
.conflicted_paths
.contains(&path)
repo.read(cx).snapshot.has_conflict(&path)
});
let git_store = cx.weak_entity();
let buffer_git_state = self
@ -1145,7 +1141,7 @@ impl GitStore {
cx: &mut Context<Self>,
) {
let id = repo.read(cx).id;
let merge_conflicts = repo.read(cx).snapshot.merge.conflicted_paths.clone();
let repo_snapshot = repo.read(cx).snapshot.clone();
for (buffer_id, diff) in self.diffs.iter() {
if let Some((buffer_repo, repo_path)) =
self.repository_and_path_for_buffer_id(*buffer_id, cx)
@ -1155,7 +1151,7 @@ impl GitStore {
if let Some(conflict_set) = &diff.conflict_set {
let conflict_status_changed =
conflict_set.update(cx, |conflict_set, cx| {
let has_conflict = merge_conflicts.contains(&repo_path);
let has_conflict = repo_snapshot.has_conflict(&repo_path);
conflict_set.set_has_conflict(has_conflict, cx)
})?;
if conflict_status_changed {
@ -2668,8 +2664,17 @@ impl RepositorySnapshot {
.ok()
}
pub fn had_conflict_on_last_merge_head_change(&self, repo_path: &RepoPath) -> bool {
self.merge.conflicted_paths.contains(&repo_path)
}
pub fn has_conflict(&self, repo_path: &RepoPath) -> bool {
self.merge.conflicted_paths.contains(repo_path)
let had_conflict_on_last_merge_head_change =
self.merge.conflicted_paths.contains(&repo_path);
let has_conflict_currently = self
.status_for_path(&repo_path)
.map_or(false, |entry| entry.status.is_conflicted());
had_conflict_on_last_merge_head_change || has_conflict_currently
}
/// This is the name that will be displayed in the repository selector for this repository.