mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
refactor: improve diff handling for EOL changes and enhance text diff… (#1177)
* refactor: improve diff handling for EOL changes and enhance text diff display - Updated `Diff.cs` to streamline whitespace handling in diff arguments. - Enhanced `DiffContext.cs` to check for EOL changes when old and new hashes differ, creating a text diff if necessary. - Added support for showing end-of-line symbols in `TextDiffView.axaml.cs` options. * localization: update translations to include EOF handling in ignore whitespace messages - Modified the ignore whitespace text in multiple language files to specify that EOF changes are also ignored. - Ensured consistency across all localization files for the patch application feature. * revert: Typo in DiffResult comment * revert: update diff arguments to ignore CR at EOL in whitespace handling (like before changes) * revert: update translations to remove EOF references in Text.Apply.IgnoreWS and fixed typo in Text.Diff.IgnoreWhitespace (EOF => EOL) --------- Co-authored-by: mpagani <massimo.pagani@unitec-group.com>
This commit is contained in:
parent
e7f0217a7b
commit
81820e7034
14 changed files with 57 additions and 13 deletions
|
@ -30,7 +30,7 @@ namespace SourceGit.Commands
|
|||
if (ignoreWhitespace)
|
||||
Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-cr-at-eol --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()
|
||||
|
|
|
@ -235,7 +235,7 @@
|
|||
<x:String x:Key="Text.Diff.Binary.Old" xml:space="preserve">ALT</x:String>
|
||||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">Kopieren</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">Dateimodus geändert</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignoriere Leerzeichenänderungen</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignoriere Leerzeichenänderungen und EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">LFS OBJEKT ÄNDERUNG</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Nächste Änderung</x:String>
|
||||
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">KEINE ÄNDERUNG ODER NUR ZEILEN-ENDE ÄNDERUNGEN</x:String>
|
||||
|
|
|
@ -241,7 +241,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">Copy</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">File Mode Changed</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">First Difference</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignore Whitespace Change</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignore Whitespace Change and EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">Last Difference</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">LFS OBJECT CHANGE</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Next Difference</x:String>
|
||||
|
|
|
@ -240,7 +240,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">Copiar</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">Modo de Archivo Cambiado</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">Primera Diferencia</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignorar Cambio de Espacios en Blanco</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignorar Cambio de Espacios en Blanco y EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">Última Diferencia</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">CAMBIO DE OBJETO LFS</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Siguiente Diferencia</x:String>
|
||||
|
|
|
@ -241,7 +241,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">Copier</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">Mode de fichier changé</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">Première différence</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignorer les changements d'espaces</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignorer les changements d'espaces et EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">Dernière différence</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">CHANGEMENT D'OBJET LFS</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Différence suivante</x:String>
|
||||
|
|
|
@ -239,7 +239,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">Copia</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">Modalità File Modificata</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">Prima differenza</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignora Modifiche agli Spazi</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignora Modifiche agli Spazi e EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">Ultima differenza</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">MODIFICA OGGETTO LFS</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Differenza Successiva</x:String>
|
||||
|
|
|
@ -240,7 +240,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">コピー</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">ファイルモードが変更されました</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">先頭の差分</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">空白の変更を無視</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">空白の変更とEOLを無視</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">最後の差分</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">LFSオブジェクトの変更</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">次の差分</x:String>
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
<x:String x:Key="Text.Diff.Binary.Old" xml:space="preserve">ANTIGO</x:String>
|
||||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">Copiar</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">Modo de Arquivo Alterado</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignorar mudanças de espaço em branco</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Ignorar mudanças de espaço em branco e EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">MUDANÇA DE OBJETO LFS</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Próxima Diferença</x:String>
|
||||
<x:String x:Key="Text.Diff.NoChange" xml:space="preserve">SEM MUDANÇAS OU APENAS MUDANÇAS DE EOL</x:String>
|
||||
|
|
|
@ -246,7 +246,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">Копировать</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">Режим файла изменён</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">Первое различие</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Игнорировать изменение пробелов</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">Игнорировать изменение пробелов и EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">Последнее различие</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">ИЗМЕНЕНИЕ ОБЪЕКТА LFS</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">Следующее различие</x:String>
|
||||
|
|
|
@ -240,7 +240,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">நகல்</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">கோப்பு முறை மாற்றப்பட்டது</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">முதல் வேறுபாடு</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">வெள்ளைவெளி மாற்றத்தை புறக்கணி</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">வெள்ளைவெளி மாற்றத்தை மற்றும் EOL புறக்கணி</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">கடைசி வேறுபாடு</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">பெகோஅ பொருள் மாற்றம்</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">அடுத்த வேறுபாடு</x:String>
|
||||
|
|
|
@ -245,7 +245,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">复制</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">文件权限已变化</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">首个差异</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">忽略空白符号变化</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">忽略空白符号变化和EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">最后一个差异</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">LFS对象变更</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">下一个差异</x:String>
|
||||
|
|
|
@ -245,7 +245,7 @@
|
|||
<x:String x:Key="Text.Diff.Copy" xml:space="preserve">複製</x:String>
|
||||
<x:String x:Key="Text.Diff.FileModeChanged" xml:space="preserve">檔案權限已變更</x:String>
|
||||
<x:String x:Key="Text.Diff.First" xml:space="preserve">第一個差異</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">忽略空白符號變化</x:String>
|
||||
<x:String x:Key="Text.Diff.IgnoreWhitespace" xml:space="preserve">忽略空白符號變化和EOL</x:String>
|
||||
<x:String x:Key="Text.Diff.Last" xml:space="preserve">最後一個差異</x:String>
|
||||
<x:String x:Key="Text.Diff.LFS" xml:space="preserve">LFS 物件變更</x:String>
|
||||
<x:String x:Key="Text.Diff.Next" xml:space="preserve">下一個差異</x:String>
|
||||
|
|
|
@ -206,9 +206,52 @@ namespace SourceGit.ViewModels
|
|||
rs = latest.LFSDiff;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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(() =>
|
||||
{
|
||||
|
|
|
@ -745,6 +745,7 @@ namespace SourceGit.Views
|
|||
var val = ShowHiddenSymbols;
|
||||
Options.ShowTabs = val;
|
||||
Options.ShowSpaces = val;
|
||||
Options.ShowEndOfLine = val;
|
||||
}
|
||||
else if (change.Property == TabWidthProperty)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue