From f72f1894c3f5bd15d3ab1a22f8e1706149fbbd76 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 23 Apr 2025 15:34:21 +0800 Subject: [PATCH] feature: supports to enable `--ignore-cr-at-eol` in diff by default Signed-off-by: leo --- src/Commands/Diff.cs | 2 ++ src/Models/DiffOption.cs | 9 +++++++++ src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/ViewModels/Preferences.cs | 13 +++++++++++++ src/Views/Preferences.axaml | 7 ++++++- 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 1434c1a5..a60f4cc5 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -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}"; } diff --git a/src/Models/DiffOption.cs b/src/Models/DiffOption.cs index 31d83cea..5f491d58 100644 --- a/src/Models/DiffOption.cs +++ b/src/Models/DiffOption.cs @@ -5,6 +5,15 @@ namespace SourceGit.Models { public class DiffOption { + /// + /// Enable `--ignore-cr-at-eol` by default? + /// + public static bool IgnoreCRAtEOL + { + get; + set; + } = false; + public Change WorkingCopyChange => _workingCopyChange; public bool IsUnstaged => _isUnstaged; public List Revisions => _revisions; diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 3c710727..538ac1f1 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -497,6 +497,7 @@ User Email Global git user email Enable --prune on fetch + Enable --ignore-cr-at-eol in diff Git (>= 2.23.0) is required by this app Install Path Enable HTTP SSL Verify diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 843c3735..db77a3ed 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -501,6 +501,7 @@ 邮箱 默认GIT用户邮箱 拉取更新时启用修剪(--prune) + 文件对比时默认启用 --ignore-cr-at-eol 选项 本软件要求GIT最低版本为2.23.0 安装路径 启用HTTP SSL验证 diff --git a/src/ViewModels/Preferences.cs b/src/ViewModels/Preferences.cs index a1830d07..d1e13f38 100644 --- a/src/ViewModels/Preferences.cs +++ b/src/ViewModels/Preferences.cs @@ -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; diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml index 702ec20f..6742bcfc 100644 --- a/src/Views/Preferences.axaml +++ b/src/Views/Preferences.axaml @@ -273,7 +273,7 @@ - + + +