diff --git a/src/Models/Change.cs b/src/Models/Change.cs
index 6e507051..e7e1b50f 100644
--- a/src/Models/Change.cs
+++ b/src/Models/Change.cs
@@ -49,7 +49,10 @@ namespace SourceGit.Models
public string OriginalPath { get; set; } = "";
public ChangeDataForAmend DataForAmend { get; set; } = null;
public ConflictReason ConflictReason { get; set; } = ConflictReason.None;
+
public bool IsConflicted => WorkTree == ChangeState.Conflicted;
+ public string ConflictMarker => CONFLICT_MARKERS[(int)ConflictReason];
+ public string ConflictDesc => CONFLICT_DESCS[(int)ConflictReason];
public void Set(ChangeState index, ChangeState workTree = ChangeState.None)
{
@@ -81,5 +84,28 @@ namespace SourceGit.Models
if (!string.IsNullOrEmpty(OriginalPath) && OriginalPath[0] == '"')
OriginalPath = OriginalPath.Substring(1, OriginalPath.Length - 2);
}
+
+ private static readonly string[] CONFLICT_MARKERS =
+ [
+ string.Empty,
+ "DD",
+ "AU",
+ "UD",
+ "UA",
+ "DU",
+ "AA",
+ "UU"
+ ];
+ private static readonly string[] CONFLICT_DESCS =
+ [
+ string.Empty,
+ "Both deleted",
+ "Added by us",
+ "Deleted by them",
+ "Added by them",
+ "Deleted by us",
+ "Both added",
+ "Both modified"
+ ];
}
}
diff --git a/src/ViewModels/ChangeTreeNode.cs b/src/ViewModels/ChangeTreeNode.cs
index 245c1dfe..6c061f65 100644
--- a/src/ViewModels/ChangeTreeNode.cs
+++ b/src/ViewModels/ChangeTreeNode.cs
@@ -17,6 +17,16 @@ namespace SourceGit.ViewModels
get => Change == null;
}
+ public bool ShowConflictMarker
+ {
+ get => Change is { IsConflicted: true };
+ }
+
+ public string ConflictMarker
+ {
+ get => Change?.ConflictMarker ?? string.Empty;
+ }
+
public bool IsExpanded
{
get => _isExpanded;
diff --git a/src/ViewModels/Conflict.cs b/src/ViewModels/Conflict.cs
index 62695f69..bf93b5bc 100644
--- a/src/ViewModels/Conflict.cs
+++ b/src/ViewModels/Conflict.cs
@@ -27,14 +27,12 @@ namespace SourceGit.ViewModels
{
public string Marker
{
- get;
- private set;
+ get => _change.ConflictMarker;
}
public string Description
{
- get;
- private set;
+ get => _change.ConflictDesc;
}
public object Theirs
@@ -67,50 +65,10 @@ namespace SourceGit.ViewModels
_change = change;
var isSubmodule = repo.Submodules.Find(x => x.Path.Equals(change.Path, StringComparison.Ordinal)) != null;
- switch (change.ConflictReason)
+ if (!isSubmodule && (_change.ConflictReason == Models.ConflictReason.BothAdded || _change.ConflictReason == Models.ConflictReason.BothModified))
{
- case Models.ConflictReason.BothDeleted:
- Marker = "DD";
- Description = "Both deleted";
- break;
- case Models.ConflictReason.AddedByUs:
- Marker = "AU";
- Description = "Added by us";
- break;
- case Models.ConflictReason.DeletedByThem:
- Marker = "UD";
- Description = "Deleted by them";
- break;
- case Models.ConflictReason.AddedByThem:
- Marker = "UA";
- Description = "Added by them";
- break;
- case Models.ConflictReason.DeletedByUs:
- Marker = "DU";
- Description = "Deleted by us";
- break;
- case Models.ConflictReason.BothAdded:
- Marker = "AA";
- Description = "Both added";
- if (!isSubmodule)
- {
- CanUseExternalMergeTool = true;
- IsResolved = new Commands.IsConflictResolved(repo.FullPath, change).Result();
- }
- break;
- case Models.ConflictReason.BothModified:
- Marker = "UU";
- Description = "Both modified";
- if (!isSubmodule)
- {
- CanUseExternalMergeTool = true;
- IsResolved = new Commands.IsConflictResolved(repo.FullPath, change).Result();
- }
- break;
- default:
- Marker = string.Empty;
- Description = string.Empty;
- break;
+ CanUseExternalMergeTool = true;
+ IsResolved = new Commands.IsConflictResolved(repo.FullPath, change).Result();
}
var context = wc.InProgressContext;
diff --git a/src/Views/ChangeCollectionView.axaml b/src/Views/ChangeCollectionView.axaml
index 36de5685..11c9e706 100644
--- a/src/Views/ChangeCollectionView.axaml
+++ b/src/Views/ChangeCollectionView.axaml
@@ -37,7 +37,7 @@
SelectionChanged="OnRowSelectionChanged">
-
-
-
+
+
+
+
+
+
@@ -84,10 +92,10 @@
IsUnstagedChange="{Binding #ThisControl.IsUnstagedChange}"
Change="{Binding}" />
-
+
+
+
+
-
+
+
+
+
diff --git a/src/Views/Conflict.axaml b/src/Views/Conflict.axaml
index a324b50f..d074bb72 100644
--- a/src/Views/Conflict.axaml
+++ b/src/Views/Conflict.axaml
@@ -105,10 +105,10 @@
-
-
-
-
+
+
+
+