From 20b45a1cf4aab43ace7d793f063d50d530508ce3 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 27 Jul 2024 21:35:57 +0800 Subject: [PATCH] fix: when base is current worktree, the diff content of selected change is wrong * remove warnings in JetBrains Rider (it seems JetBrains can NOT recognize Binding.TargetNullValue) --- src/Models/DiffOption.cs | 2 +- src/Models/Null.cs | 6 ++++++ src/SourceGit.csproj | 4 ++-- src/ViewModels/Discard.cs | 4 ++-- src/ViewModels/RevisionCompare.cs | 4 ++-- src/Views/Discard.axaml | 23 ++++++++++------------- src/Views/RevisionCompare.axaml | 30 ++++++++---------------------- 7 files changed, 31 insertions(+), 42 deletions(-) create mode 100644 src/Models/Null.cs diff --git a/src/Models/DiffOption.cs b/src/Models/DiffOption.cs index f5bec602..e122ad67 100644 --- a/src/Models/DiffOption.cs +++ b/src/Models/DiffOption.cs @@ -80,7 +80,7 @@ namespace SourceGit.Models /// public DiffOption(string baseRevision, string targetRevision, Change change) { - _revisions.Add(baseRevision); + _revisions.Add(string.IsNullOrEmpty(baseRevision) ? "-R" : baseRevision); _revisions.Add(targetRevision); _path = change.Path; _orgPath = change.OriginalPath; diff --git a/src/Models/Null.cs b/src/Models/Null.cs new file mode 100644 index 00000000..e22ef8b3 --- /dev/null +++ b/src/Models/Null.cs @@ -0,0 +1,6 @@ +namespace SourceGit.Models +{ + public class Null + { + } +} diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj index 3f6aabc9..ecb55bd2 100644 --- a/src/SourceGit.csproj +++ b/src/SourceGit.csproj @@ -52,7 +52,7 @@ - + - \ No newline at end of file + diff --git a/src/ViewModels/Discard.cs b/src/ViewModels/Discard.cs index 641c5232..f37d5f0c 100644 --- a/src/ViewModels/Discard.cs +++ b/src/ViewModels/Discard.cs @@ -15,7 +15,7 @@ namespace SourceGit.ViewModels { _repo = repo; - Mode = null; + Mode = new Models.Null(); View = new Views.Discard { DataContext = this }; } @@ -26,7 +26,7 @@ namespace SourceGit.ViewModels _isUnstaged = isUnstaged; if (_changes == null) - Mode = null; + Mode = new Models.Null(); else if (_changes.Count == 1) Mode = _changes[0].Path; else diff --git a/src/ViewModels/RevisionCompare.cs b/src/ViewModels/RevisionCompare.cs index 8ac6f823..55c85129 100644 --- a/src/ViewModels/RevisionCompare.cs +++ b/src/ViewModels/RevisionCompare.cs @@ -71,8 +71,8 @@ namespace SourceGit.ViewModels public RevisionCompare(string repo, Models.Commit startPoint, Models.Commit endPoint) { _repo = repo; - _startPoint = startPoint; - _endPoint = endPoint; + _startPoint = (object)startPoint ?? new Models.Null(); + _endPoint = (object)endPoint ?? new Models.Null(); Task.Run(Refresh); } diff --git a/src/Views/Discard.axaml b/src/Views/Discard.axaml index 73532887..e67600d7 100644 --- a/src/Views/Discard.axaml +++ b/src/Views/Discard.axaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:m="using:SourceGit.Models" xmlns:vm="using:SourceGit.ViewModels" xmlns:c="using:SourceGit.Converters" mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450" @@ -14,19 +15,15 @@ - - - - - - - - - - - - + + + + + + + + @@ -37,7 +34,7 @@ - + diff --git a/src/Views/RevisionCompare.axaml b/src/Views/RevisionCompare.axaml index 52bd8d9e..14ac66a7 100644 --- a/src/Views/RevisionCompare.axaml +++ b/src/Views/RevisionCompare.axaml @@ -11,6 +11,12 @@ x:DataType="vm:RevisionCompare" Background="{DynamicResource Brush.Window}"> + + + + + + @@ -33,17 +39,7 @@ - - - - - - - - - - - + @@ -53,17 +49,7 @@ - - - - - - - - - - - +