mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
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)
This commit is contained in:
parent
4612cecf10
commit
20b45a1cf4
7 changed files with 31 additions and 42 deletions
|
@ -80,7 +80,7 @@ namespace SourceGit.Models
|
||||||
/// <param name="change"></param>
|
/// <param name="change"></param>
|
||||||
public DiffOption(string baseRevision, string targetRevision, Change change)
|
public DiffOption(string baseRevision, string targetRevision, Change change)
|
||||||
{
|
{
|
||||||
_revisions.Add(baseRevision);
|
_revisions.Add(string.IsNullOrEmpty(baseRevision) ? "-R" : baseRevision);
|
||||||
_revisions.Add(targetRevision);
|
_revisions.Add(targetRevision);
|
||||||
_path = change.Path;
|
_path = change.Path;
|
||||||
_orgPath = change.OriginalPath;
|
_orgPath = change.OriginalPath;
|
||||||
|
|
6
src/Models/Null.cs
Normal file
6
src/Models/Null.cs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
namespace SourceGit.Models
|
||||||
|
{
|
||||||
|
public class Null
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,7 +52,7 @@
|
||||||
<TrimmerRootAssembly Include="Avalonia.Themes.Fluent" />
|
<TrimmerRootAssembly Include="Avalonia.Themes.Fluent" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
<LinkerArg Include="-mmacosx-version-min=11.0" Condition="$([MSBuild]::IsOSPlatform('OSX'))"/>
|
<LinkerArg Include="-mmacosx-version-min=11.0" Condition="$([MSBuild]::IsOSPlatform('OSX'))"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -15,7 +15,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
|
|
||||||
Mode = null;
|
Mode = new Models.Null();
|
||||||
View = new Views.Discard { DataContext = this };
|
View = new Views.Discard { DataContext = this };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace SourceGit.ViewModels
|
||||||
_isUnstaged = isUnstaged;
|
_isUnstaged = isUnstaged;
|
||||||
|
|
||||||
if (_changes == null)
|
if (_changes == null)
|
||||||
Mode = null;
|
Mode = new Models.Null();
|
||||||
else if (_changes.Count == 1)
|
else if (_changes.Count == 1)
|
||||||
Mode = _changes[0].Path;
|
Mode = _changes[0].Path;
|
||||||
else
|
else
|
||||||
|
|
|
@ -71,8 +71,8 @@ namespace SourceGit.ViewModels
|
||||||
public RevisionCompare(string repo, Models.Commit startPoint, Models.Commit endPoint)
|
public RevisionCompare(string repo, Models.Commit startPoint, Models.Commit endPoint)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_startPoint = startPoint;
|
_startPoint = (object)startPoint ?? new Models.Null();
|
||||||
_endPoint = endPoint;
|
_endPoint = (object)endPoint ?? new Models.Null();
|
||||||
|
|
||||||
Task.Run(Refresh);
|
Task.Run(Refresh);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:m="using:SourceGit.Models"
|
||||||
xmlns:vm="using:SourceGit.ViewModels"
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
xmlns:c="using:SourceGit.Converters"
|
xmlns:c="using:SourceGit.Converters"
|
||||||
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450"
|
||||||
|
@ -14,19 +15,15 @@
|
||||||
|
|
||||||
<Grid Margin="0,16,0,8" RowDefinitions="32,32" ColumnDefinitions="120,*">
|
<Grid Margin="0,16,0,8" RowDefinitions="32,32" ColumnDefinitions="120,*">
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,8,0" HorizontalAlignment="Right" Text="{DynamicResource Text.Discard.Changes}"/>
|
<TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,8,0" HorizontalAlignment="Right" Text="{DynamicResource Text.Discard.Changes}"/>
|
||||||
<ContentControl Grid.Row="0" Grid.Column="1">
|
<ContentControl Grid.Row="0" Grid.Column="1" Content="{Binding Mode}">
|
||||||
<ContentControl.Content>
|
<ContentControl.DataTemplates>
|
||||||
<Binding Path="Mode">
|
<DataTemplate DataType="m:Null">
|
||||||
<Binding.TargetNullValue>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Path Width="12" Height="12" Margin="0,2,0,0" Data="{StaticResource Icons.Folder.Open}"/>
|
<Path Width="12" Height="12" Margin="0,2,0,0" Data="{StaticResource Icons.Folder.Open}"/>
|
||||||
<TextBlock Text="{DynamicResource Text.Discard.All}" Margin="4,0,0,0"/>
|
<TextBlock Text="{DynamicResource Text.Discard.All}" Margin="4,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Binding.TargetNullValue>
|
</DataTemplate>
|
||||||
</Binding>
|
|
||||||
</ContentControl.Content>
|
|
||||||
|
|
||||||
<ContentControl.DataTemplates>
|
|
||||||
<DataTemplate DataType="x:String">
|
<DataTemplate DataType="x:String">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Path Width="12" Height="12" Data="{StaticResource Icons.File}"/>
|
<Path Width="12" Height="12" Data="{StaticResource Icons.File}"/>
|
||||||
|
@ -37,7 +34,7 @@
|
||||||
<DataTemplate DataType="x:Int32">
|
<DataTemplate DataType="x:Int32">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Path Width="12" Height="12" Data="{StaticResource Icons.File}"/>
|
<Path Width="12" Height="12" Data="{StaticResource Icons.File}"/>
|
||||||
<TextBlock Text="{Binding, Converter={x:Static c:StringConverters.FormatByResourceKey}, ConverterParameter='Discard.Total'}" Margin="4,0,0,0"/>
|
<TextBlock Text="{Binding Converter={x:Static c:StringConverters.FormatByResourceKey}, ConverterParameter='Discard.Total'}" Margin="4,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ContentControl.DataTemplates>
|
</ContentControl.DataTemplates>
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
x:DataType="vm:RevisionCompare"
|
x:DataType="vm:RevisionCompare"
|
||||||
Background="{DynamicResource Brush.Window}">
|
Background="{DynamicResource Brush.Window}">
|
||||||
<UserControl.DataTemplates>
|
<UserControl.DataTemplates>
|
||||||
|
<DataTemplate DataType="m:Null">
|
||||||
|
<Border HorizontalAlignment="Center" VerticalAlignment="Center" Background="{DynamicResource Brush.Accent}" CornerRadius="4">
|
||||||
|
<TextBlock Text="{DynamicResource Text.Worktree}" Classes="monospace" Margin="4,2" Foreground="#FFDDDDDD"/>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
<DataTemplate DataType="m:Commit">
|
<DataTemplate DataType="m:Commit">
|
||||||
<Grid RowDefinitions="Auto,*">
|
<Grid RowDefinitions="Auto,*">
|
||||||
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto,Auto">
|
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto,Auto">
|
||||||
|
@ -33,17 +39,7 @@
|
||||||
<Grid Grid.Row="0" Margin="48,0,48,4" ColumnDefinitions="*,48,*">
|
<Grid Grid.Row="0" Margin="48,0,48,4" ColumnDefinitions="*,48,*">
|
||||||
<!-- Base Revision -->
|
<!-- Base Revision -->
|
||||||
<Border Grid.Column="0" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}" CornerRadius="4" Padding="4">
|
<Border Grid.Column="0" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}" CornerRadius="4" Padding="4">
|
||||||
<ContentControl>
|
<ContentControl Content="{Binding StartPoint}"/>
|
||||||
<ContentControl.Content>
|
|
||||||
<Binding Path="StartPoint">
|
|
||||||
<Binding.TargetNullValue>
|
|
||||||
<Border HorizontalAlignment="Center" VerticalAlignment="Center" Background="{DynamicResource Brush.Accent}" CornerRadius="4">
|
|
||||||
<TextBlock Text="{DynamicResource Text.Worktree}" Classes="monospace" Margin="4,2" Foreground="#FFDDDDDD"/>
|
|
||||||
</Border>
|
|
||||||
</Binding.TargetNullValue>
|
|
||||||
</Binding>
|
|
||||||
</ContentControl.Content>
|
|
||||||
</ContentControl>
|
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- Swap Button -->
|
<!-- Swap Button -->
|
||||||
|
@ -53,17 +49,7 @@
|
||||||
|
|
||||||
<!-- Right Revision -->
|
<!-- Right Revision -->
|
||||||
<Border Grid.Column="2" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}" CornerRadius="4" Padding="4">
|
<Border Grid.Column="2" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}" CornerRadius="4" Padding="4">
|
||||||
<ContentControl>
|
<ContentControl Content="{Binding EndPoint}"/>
|
||||||
<ContentControl.Content>
|
|
||||||
<Binding Path="EndPoint">
|
|
||||||
<Binding.TargetNullValue>
|
|
||||||
<Border HorizontalAlignment="Center" VerticalAlignment="Center" Background="{DynamicResource Brush.Accent}" CornerRadius="4">
|
|
||||||
<TextBlock Text="{DynamicResource Text.Worktree}" Classes="monospace" Margin="4,2" Foreground="#FFDDDDDD"/>
|
|
||||||
</Border>
|
|
||||||
</Binding.TargetNullValue>
|
|
||||||
</Binding>
|
|
||||||
</ContentControl.Content>
|
|
||||||
</ContentControl>
|
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue