From c8a681e1b587bdca5339bdbe84734e77f35f36d9 Mon Sep 17 00:00:00 2001 From: Sina Hinderks Date: Fri, 11 Jul 2025 01:32:10 +0200 Subject: [PATCH] fix: prevent staging conflicted files It was possible to stage a file with conflicts (double tap, space, enter, or a stage button). As a result it would no longer be shown as conflicted, and the user could no longer solve the conflict in any way (use theirs, use mine, or execute merge tool), not even after unstaging again. Now conflicted files are ignored when staging. --- src/ViewModels/WorkingCopy.cs | 9 +++++++-- src/Views/ChangeCollectionView.axaml.cs | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index d8ec3326d..7580c73c5 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; using Avalonia.Controls; @@ -1870,7 +1871,11 @@ private void UpdateInProgressState() private async void StageChanges(List changes, Models.Change next) { - var count = changes.Count; + var nonConflictChanges = HasUnsolvedConflicts + ? changes.Where(c => !c.IsConflicted).ToList() + : changes; + + var count = nonConflictChanges.Count; if (count == 0) return; @@ -1890,7 +1895,7 @@ private async void StageChanges(List changes, Models.Change next) var pathSpecFile = Path.GetTempFileName(); await using (var writer = new StreamWriter(pathSpecFile)) { - foreach (var c in changes) + foreach (var c in nonConflictChanges) await writer.WriteLineAsync(c.Path); } diff --git a/src/Views/ChangeCollectionView.axaml.cs b/src/Views/ChangeCollectionView.axaml.cs index ba7491411..8b9f90586 100644 --- a/src/Views/ChangeCollectionView.axaml.cs +++ b/src/Views/ChangeCollectionView.axaml.cs @@ -186,7 +186,10 @@ public Models.Change GetNextChangeWithoutSelection() var set = new HashSet(); foreach (var c in selected) - set.Add(c.Path); + { + if (!c.IsConflicted) + set.Add(c.Path); + } if (Content is ViewModels.ChangeCollectionAsTree tree) {