Skip to content

Commit efe0ef0

Browse files
committed
CompareOptions: Add an enum PatchWhiteSpaceMode.
This will allow using the following diff options: --ignore-space-at-eol --ignore-space-change --ignore-all-space
1 parent 4de700f commit efe0ef0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

LibGit2Sharp/CompareOptions.cs

+29
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22

33
namespace LibGit2Sharp
44
{
5+
/// <summary>
6+
/// Represents a mode for handling whitespace while creating a patch.
7+
/// </summary>
8+
public enum PatchWhitespaceMode
9+
{
10+
/// <summary>
11+
/// Do not ignore changes in whitespace when comparing lines.
12+
/// </summary>
13+
DontIgnoreWhitespace = 0,
14+
/// <summary>
15+
/// Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.
16+
/// </summary>
17+
IgnoreAllWhitespace = 1,
18+
/// <summary>
19+
/// Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.
20+
/// </summary>
21+
IgnoreWhitespaceChange = 2,
22+
/// <summary>
23+
/// Ignore changes in whitespace at EOL.
24+
/// </summary>
25+
IgnoreWhitespaceEol = 3,
26+
}
27+
528
/// <summary>
629
/// Options to define file comparison behavior.
730
/// </summary>
@@ -14,6 +37,7 @@ public CompareOptions()
1437
{
1538
ContextLines = 3;
1639
InterhunkLines = 0;
40+
PatchWhitespaceMode = PatchWhitespaceMode.DontIgnoreWhitespace;
1741
Algorithm = DiffAlgorithm.Myers;
1842
}
1943

@@ -29,6 +53,11 @@ public CompareOptions()
2953
/// </summary>
3054
public int InterhunkLines { get; set; }
3155

56+
/// <summary>
57+
/// The mode for handling whitespace when comparing lines
58+
/// </summary>
59+
public PatchWhitespaceMode PatchWhitespaceMode { get; set; }
60+
3261
/// <summary>
3362
/// Options for rename detection. If null, the `diff.renames` configuration setting is used.
3463
/// </summary>

0 commit comments

Comments
 (0)