Skip to content

Commit 2f583cb

Browse files
committed
Check the same lines have been added or removed
The --indent-heuristic option should create patches that add or remove the same lines, but potentially in a different order.
1 parent e063680 commit 2f583cb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.IO;
2+
using System.Linq;
23
using System.Text;
34
using LibGit2Sharp.Tests.TestHelpers;
45
using Xunit;
@@ -163,10 +164,10 @@ public void ComparingBlobsWithNoSpacesAndIndentHeuristicOptionMakesADifference()
163164
ContentChanges changes1 = repo.Diff.Compare(oldBlob, newBlob, indentHeuristicOption);
164165

165166
Assert.NotEqual(changes0.Patch, changes1.Patch);
167+
Assert.Equal(CanonicalChangedLines(changes0), CanonicalChangedLines(changes1));
166168
}
167169
}
168170

169-
170171
[Fact]
171172
public void ComparingBlobsWithNoSpacesIndentHeuristicOptionMakesNoDifference()
172173
{
@@ -200,5 +201,11 @@ public void ComparingBlobsWithNoSpacesIndentHeuristicOptionMakesNoDifference()
200201
Assert.Equal(changes0.Patch, changes1.Patch);
201202
}
202203
}
204+
205+
static string CanonicalChangedLines(ContentChanges changes)
206+
{
207+
// Create an ordered representation of lines that have been added or removed
208+
return string.Join("\n", changes.Patch.Split('\n').Where(l => l.StartsWith("+") || l.StartsWith("-")).OrderBy(l => l));
209+
}
203210
}
204211
}

0 commit comments

Comments
 (0)