Skip to content

Commit c8a681e

Browse files
committed
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.
1 parent d5745b4 commit c8a681e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/ViewModels/WorkingCopy.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Linq;
45
using System.Threading.Tasks;
56

67
using Avalonia.Controls;
@@ -1870,7 +1871,11 @@ private void UpdateInProgressState()
18701871

18711872
private async void StageChanges(List<Models.Change> changes, Models.Change next)
18721873
{
1873-
var count = changes.Count;
1874+
var nonConflictChanges = HasUnsolvedConflicts
1875+
? changes.Where(c => !c.IsConflicted).ToList()
1876+
: changes;
1877+
1878+
var count = nonConflictChanges.Count;
18741879
if (count == 0)
18751880
return;
18761881

@@ -1890,7 +1895,7 @@ private async void StageChanges(List<Models.Change> changes, Models.Change next)
18901895
var pathSpecFile = Path.GetTempFileName();
18911896
await using (var writer = new StreamWriter(pathSpecFile))
18921897
{
1893-
foreach (var c in changes)
1898+
foreach (var c in nonConflictChanges)
18941899
await writer.WriteLineAsync(c.Path);
18951900
}
18961901

src/Views/ChangeCollectionView.axaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ public Models.Change GetNextChangeWithoutSelection()
186186

187187
var set = new HashSet<string>();
188188
foreach (var c in selected)
189-
set.Add(c.Path);
189+
{
190+
if (!c.IsConflicted)
191+
set.Add(c.Path);
192+
}
190193

191194
if (Content is ViewModels.ChangeCollectionAsTree tree)
192195
{

0 commit comments

Comments
 (0)