From 4419b734a5722b6f21023a05adb7bdb1562ddd18 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 19 Nov 2025 10:28:36 +0800 Subject: [PATCH] enhance: always turn off `--color=` and `--ext-diff` when calling `git diff` in `SourceGit` (#1922) Signed-off-by: leo --- src/Commands/Diff.cs | 6 +++--- src/Commands/GenerateCommitMessage.cs | 2 +- src/Commands/IsBinary.cs | 2 +- src/Commands/IsConflictResolved.cs | 2 +- src/Commands/SaveChangesAsPatch.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index ffd60d4e..ce98756f 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -26,11 +26,11 @@ namespace SourceGit.Commands Context = repo; if (ignoreWhitespace) - Args = $"diff --no-ext-diff --patch --ignore-all-space --unified={unified} {opt}"; + Args = $"diff --no-color --no-ext-diff --patch --ignore-all-space --unified={unified} {opt}"; else if (Models.DiffOption.IgnoreCRAtEOL) - Args = $"diff --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}"; + Args = $"diff --no-color --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}"; else - Args = $"diff --no-ext-diff --patch --unified={unified} {opt}"; + Args = $"diff --no-color --no-ext-diff --patch --unified={unified} {opt}"; } public async Task ReadAsync() diff --git a/src/Commands/GenerateCommitMessage.cs b/src/Commands/GenerateCommitMessage.cs index 4889881b..bbefa34e 100644 --- a/src/Commands/GenerateCommitMessage.cs +++ b/src/Commands/GenerateCommitMessage.cs @@ -17,7 +17,7 @@ namespace SourceGit.Commands { WorkingDirectory = repo; Context = repo; - Args = $"diff --diff-algorithm=minimal {opt}"; + Args = $"diff --no-color --no-ext-diff --diff-algorithm=minimal {opt}"; } public async Task ReadAsync() diff --git a/src/Commands/IsBinary.cs b/src/Commands/IsBinary.cs index 0e60f38c..087e71c7 100644 --- a/src/Commands/IsBinary.cs +++ b/src/Commands/IsBinary.cs @@ -12,7 +12,7 @@ namespace SourceGit.Commands { WorkingDirectory = repo; Context = repo; - Args = $"diff {Models.Commit.EmptyTreeSHA1} {commit} --numstat -- {path.Quoted()}"; + Args = $"diff --no-color --no-ext-diff --numstat {Models.Commit.EmptyTreeSHA1} {commit} -- {path.Quoted()}"; RaiseError = false; } diff --git a/src/Commands/IsConflictResolved.cs b/src/Commands/IsConflictResolved.cs index d13fccf1..e5b752d3 100644 --- a/src/Commands/IsConflictResolved.cs +++ b/src/Commands/IsConflictResolved.cs @@ -10,7 +10,7 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; - Args = $"diff -a --ignore-cr-at-eol --check {opt}"; + Args = $"diff --no-color --no-ext-diff -a --ignore-cr-at-eol --check {opt}"; } public bool GetResult() diff --git a/src/Commands/SaveChangesAsPatch.cs b/src/Commands/SaveChangesAsPatch.cs index 4352319a..51bc1319 100644 --- a/src/Commands/SaveChangesAsPatch.cs +++ b/src/Commands/SaveChangesAsPatch.cs @@ -54,7 +54,7 @@ namespace SourceGit.Commands var starter = new ProcessStartInfo(); starter.WorkingDirectory = repo; starter.FileName = Native.OS.GitExecutable; - starter.Arguments = $"diff --ignore-cr-at-eol --unified=4 {opt}"; + starter.Arguments = $"diff --no-color --no-ext-diff --ignore-cr-at-eol --unified=4 {opt}"; starter.UseShellExecute = false; starter.CreateNoWindow = true; starter.WindowStyle = ProcessWindowStyle.Hidden;