feature: supports to enable --ignore-cr-at-eol in diff by default

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-23 15:34:21 +08:00
parent 586ff39da1
commit f72f1894c3
No known key found for this signature in database
6 changed files with 32 additions and 1 deletions

View file

@ -29,6 +29,8 @@ namespace SourceGit.Commands
if (ignoreWhitespace)
Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-all-space --unified={unified} {opt}";
else if (Models.DiffOption.IgnoreCRAtEOL)
Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}";
else
Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --unified={unified} {opt}";
}

View file

@ -5,6 +5,15 @@ namespace SourceGit.Models
{
public class DiffOption
{
/// <summary>
/// Enable `--ignore-cr-at-eol` by default?
/// </summary>
public static bool IgnoreCRAtEOL
{
get;
set;
} = false;
public Change WorkingCopyChange => _workingCopyChange;
public bool IsUnstaged => _isUnstaged;
public List<string> Revisions => _revisions;

View file

@ -497,6 +497,7 @@
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">User Email</x:String>
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Global git user email</x:String>
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Enable --prune on fetch</x:String>
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">Enable --ignore-cr-at-eol in diff</x:String>
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (&gt;= 2.23.0) is required by this app</x:String>
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Install Path</x:String>
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Enable HTTP SSL Verify</x:String>

View file

@ -501,6 +501,7 @@
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">邮箱</x:String>
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">默认GIT用户邮箱</x:String>
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">拉取更新时启用修剪(--prune</x:String>
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">文件对比时默认启用 --ignore-cr-at-eol 选项</x:String>
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">本软件要求GIT最低版本为2.23.0</x:String>
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">安装路径</x:String>
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">启用HTTP SSL验证</x:String>

View file

@ -212,6 +212,19 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _useSyntaxHighlighting, value);
}
public bool IgnoreCRAtEOLInDiff
{
get => Models.DiffOption.IgnoreCRAtEOL;
set
{
if (Models.DiffOption.IgnoreCRAtEOL != value)
{
Models.DiffOption.IgnoreCRAtEOL = value;
OnPropertyChanged();
}
}
}
public bool IgnoreWhitespaceChangesInDiff
{
get => _ignoreWhitespaceChangesInDiff;

View file

@ -273,7 +273,7 @@
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preferences.Git}"/>
</TabItem.Header>
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
<TextBlock Grid.Row="0" Grid.Column="0"
Text="{DynamicResource Text.Preferences.Git.Path}"
HorizontalAlignment="Right"
@ -352,6 +352,11 @@
IsChecked="{Binding #ThisControl.EnablePruneOnFetch, Mode=TwoWay}"/>
<CheckBox Grid.Row="6" Grid.Column="1"
Height="32"
Content="{DynamicResource Text.Preferences.Git.IgnoreCRAtEOLInDiff}"
IsChecked="{Binding IgnoreCRAtEOLInDiff, Mode=TwoWay}"/>
<CheckBox Grid.Row="7" Grid.Column="1"
Height="32"
Content="{DynamicResource Text.Preferences.Git.SSLVerify}"
IsChecked="{Binding #ThisControl.EnableHTTPSSLVerify, Mode=TwoWay}"/>