diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 8ae6350f..1c0d8362 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -28,9 +28,9 @@ namespace SourceGit.Commands Context = repo; if (ignoreWhitespace) - Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-cr-at-eol --ignore-all-space --unified={unified} {opt}"; + Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-all-space --unified={unified} {opt}"; else - Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}"; + Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --unified={unified} {opt}"; } public Models.DiffResult Result() diff --git a/src/Models/DiffResult.cs b/src/Models/DiffResult.cs index 88992e10..fbe90a0a 100644 --- a/src/Models/DiffResult.cs +++ b/src/Models/DiffResult.cs @@ -656,6 +656,7 @@ namespace SourceGit.Models public class NoOrEOLChange { + // The empty class is kept for backward compatibility } public class FileModeDiff diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index 6dd836bf..0feb7d77 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -207,7 +207,50 @@ namespace SourceGit.ViewModels } else { - rs = new Models.NoOrEOLChange(); + // Check if old and new hashes differ but no text changes found + if (!string.IsNullOrEmpty(latest.OldHash) && + !string.IsNullOrEmpty(latest.NewHash) && + latest.OldHash != latest.NewHash) + { + // If hashes differ but no text diff found, it's likely an EOL change + // Create a text diff to show the file content + var textDiff = new Models.TextDiff() + { + Repo = _repo, + Option = _option, + File = _option.Path + }; + // Query the file content to show + var fileContent = Commands.QueryFileContent.Run(_repo, "HEAD", _option.Path); + using var reader = new StreamReader(fileContent); + var line = string.Empty; + int lineNumber = 1; + + while ((line = reader.ReadLine()) != null) + { + textDiff.Lines.Add(new Models.TextDiffLine( + Models.TextDiffLineType.Normal, + line, + lineNumber, + lineNumber)); + + lineNumber++; + } + + if (textDiff.Lines.Count > 0) + { + textDiff.MaxLineNumber = lineNumber - 1; + rs = textDiff; + } + else + { + rs = new Models.NoOrEOLChange(); + } + } + else + { + rs = new Models.NoOrEOLChange(); + } } Dispatcher.UIThread.Post(() => diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index 7ce9f288..fa065fed 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -745,6 +745,7 @@ namespace SourceGit.Views var val = ShowHiddenSymbols; Options.ShowTabs = val; Options.ShowSpaces = val; + Options.ShowEndOfLine = val; } else if (change.Property == TabWidthProperty) {