mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
code_review: PR #1177
- use `Command.ReadToEnd` instead of `Command.Exec` to avoid git trims line endings. - use `StringBuilder.Append('\n')` instead of `StringBuilder.AppendLine()` to restore original line endings (we split the original diff output by `\n` not `\r') - there's no need to show file content (the `StreamReader.ReadLine()` will trim line endings) Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
81820e7034
commit
e89dbd8f43
3 changed files with 31 additions and 53 deletions
|
@ -207,50 +207,7 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
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();
|
||||
}
|
||||
rs = new Models.NoOrEOLChange();
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue