From cd2ecb109aee3e2fcf6ab6c5052cff033fe46c03 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 14 Mar 2024 10:55:25 +0800 Subject: [PATCH] enhance: diff with LFS filtered files --- src/Commands/Diff.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 611bb9a2..8003922b 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -39,20 +39,18 @@ namespace SourceGit.Commands { if (_result.IsLFS) { var ch = line[0]; if (ch == '-') { - line = line.Substring(1); - if (line.StartsWith("oid sha256:")) { - _result.LFSDiff.Old.Oid = line.Substring(11); - } else if (line.StartsWith("size ")) { - _result.LFSDiff.Old.Size = long.Parse(line.Substring(5)); + if (line.StartsWith("-oid sha256:", StringComparison.Ordinal)) { + _result.LFSDiff.Old.Oid = line.Substring(12); + } else if (line.StartsWith("-size ", StringComparison.Ordinal)) { + _result.LFSDiff.Old.Size = long.Parse(line.Substring(6)); } } else if (ch == '+') { - line = line.Substring(1); - if (line.StartsWith("oid sha256:")) { - _result.LFSDiff.New.Oid = line.Substring(11); - } else if (line.StartsWith("size ")) { - _result.LFSDiff.New.Size = long.Parse(line.Substring(5)); + if (line.StartsWith("+oid sha256:", StringComparison.Ordinal)) { + _result.LFSDiff.New.Oid = line.Substring(12); + } else if (line.StartsWith("+size ", StringComparison.Ordinal)) { + _result.LFSDiff.New.Size = long.Parse(line.Substring(6)); } - } else if (line.StartsWith(" size ")) { + } else if (line.StartsWith(" size ", StringComparison.Ordinal)) { _result.LFSDiff.New.Size = _result.LFSDiff.Old.Size = long.Parse(line.Substring(6)); } return;