Skip to content

Commit f72f189

Browse files
committed
feature: supports to enable --ignore-cr-at-eol in diff by default
Signed-off-by: leo <[email protected]>
1 parent 586ff39 commit f72f189

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

src/Commands/Diff.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public Diff(string repo, Models.DiffOption opt, int unified, bool ignoreWhitespa
2929

3030
if (ignoreWhitespace)
3131
Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-all-space --unified={unified} {opt}";
32+
else if (Models.DiffOption.IgnoreCRAtEOL)
33+
Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}";
3234
else
3335
Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --unified={unified} {opt}";
3436
}

src/Models/DiffOption.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ namespace SourceGit.Models
55
{
66
public class DiffOption
77
{
8+
/// <summary>
9+
/// Enable `--ignore-cr-at-eol` by default?
10+
/// </summary>
11+
public static bool IgnoreCRAtEOL
12+
{
13+
get;
14+
set;
15+
} = false;
16+
817
public Change WorkingCopyChange => _workingCopyChange;
918
public bool IsUnstaged => _isUnstaged;
1019
public List<string> Revisions => _revisions;

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@
497497
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">User Email</x:String>
498498
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Global git user email</x:String>
499499
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Enable --prune on fetch</x:String>
500+
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">Enable --ignore-cr-at-eol in diff</x:String>
500501
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (&gt;= 2.23.0) is required by this app</x:String>
501502
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Install Path</x:String>
502503
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Enable HTTP SSL Verify</x:String>

src/Resources/Locales/zh_CN.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@
501501
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">邮箱</x:String>
502502
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">默认GIT用户邮箱</x:String>
503503
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">拉取更新时启用修剪(--prune)</x:String>
504+
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">文件对比时默认启用 --ignore-cr-at-eol 选项</x:String>
504505
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">本软件要求GIT最低版本为2.23.0</x:String>
505506
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">安装路径</x:String>
506507
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">启用HTTP SSL验证</x:String>

src/ViewModels/Preferences.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,19 @@ public bool UseSyntaxHighlighting
212212
set => SetProperty(ref _useSyntaxHighlighting, value);
213213
}
214214

215+
public bool IgnoreCRAtEOLInDiff
216+
{
217+
get => Models.DiffOption.IgnoreCRAtEOL;
218+
set
219+
{
220+
if (Models.DiffOption.IgnoreCRAtEOL != value)
221+
{
222+
Models.DiffOption.IgnoreCRAtEOL = value;
223+
OnPropertyChanged();
224+
}
225+
}
226+
}
227+
215228
public bool IgnoreWhitespaceChangesInDiff
216229
{
217230
get => _ignoreWhitespaceChangesInDiff;

src/Views/Preferences.axaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preferences.Git}"/>
274274
</TabItem.Header>
275275

276-
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
276+
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
277277
<TextBlock Grid.Row="0" Grid.Column="0"
278278
Text="{DynamicResource Text.Preferences.Git.Path}"
279279
HorizontalAlignment="Right"
@@ -352,6 +352,11 @@
352352
IsChecked="{Binding #ThisControl.EnablePruneOnFetch, Mode=TwoWay}"/>
353353

354354
<CheckBox Grid.Row="6" Grid.Column="1"
355+
Height="32"
356+
Content="{DynamicResource Text.Preferences.Git.IgnoreCRAtEOLInDiff}"
357+
IsChecked="{Binding IgnoreCRAtEOLInDiff, Mode=TwoWay}"/>
358+
359+
<CheckBox Grid.Row="7" Grid.Column="1"
355360
Height="32"
356361
Content="{DynamicResource Text.Preferences.Git.SSLVerify}"
357362
IsChecked="{Binding #ThisControl.EnableHTTPSSLVerify, Mode=TwoWay}"/>

0 commit comments

Comments
 (0)