diff --git a/LibGit2Sharp/CompareOptions.cs b/LibGit2Sharp/CompareOptions.cs
index fb4234439..abf67c32d 100644
--- a/LibGit2Sharp/CompareOptions.cs
+++ b/LibGit2Sharp/CompareOptions.cs
@@ -2,6 +2,25 @@
namespace LibGit2Sharp
{
+ ///
+ /// Represents a mode for handling whitespace while making diff.
+ ///
+ public enum DiffWhitespaceMode
+ {
+ ///
+ /// Ignore all whitespace
+ ///
+ IgnoreAllWhitespaces,
+ ///
+ /// Ignore changes in amount of whitespace
+ ///
+ IgnoreWhitespaceChange,
+ ///
+ /// Ignore whitespace at end of line
+ ///
+ IgnoreWhitespaceEol
+ }
+
///
/// Options to define file comparison behavior.
///
@@ -34,6 +53,12 @@ public CompareOptions()
///
public SimilarityOptions Similarity { get; set; }
+ ///
+ /// Represents a mode for handling whitespace while making diff.
+ /// By default is null - it means no extra flag is passed
+ ///
+ public DiffWhitespaceMode? WhitespaceMode { get; set; }
+
///
/// Include "unmodified" entries in the results.
///
diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs
index 087ee8d6d..5ac438561 100644
--- a/LibGit2Sharp/Diff.cs
+++ b/LibGit2Sharp/Diff.cs
@@ -58,6 +58,22 @@ private static GitDiffOptions BuildOptions(DiffModifiers diffOptions, FilePath[]
options.Flags |= GitDiffOptionFlags.GIT_DIFF_MINIMAL;
}
+ if (compareOptions.WhitespaceMode != null)
+ {
+ if (compareOptions.WhitespaceMode == DiffWhitespaceMode.IgnoreAllWhitespaces)
+ {
+ options.Flags |= GitDiffOptionFlags.GIT_DIFF_IGNORE_WHITESPACE;
+ }
+ else if (compareOptions.WhitespaceMode == DiffWhitespaceMode.IgnoreWhitespaceChange)
+ {
+ options.Flags |= GitDiffOptionFlags.GIT_DIFF_IGNORE_WHITESPACE_CHANGE;
+ }
+ else
+ {
+ options.Flags |= GitDiffOptionFlags.GIT_DIFF_IGNORE_WHITESPACE_EOL;
+ }
+ }
+
if (diffOptions.HasFlag(DiffModifiers.DisablePathspecMatch))
{
options.Flags |= GitDiffOptionFlags.GIT_DIFF_DISABLE_PATHSPEC_MATCH;
@@ -546,7 +562,7 @@ private DiffHandle BuildDiffList(
MatchedPathsAggregator matchedPaths = null;
- // We can't match paths unless we've got something to match
+ // We can't match paths unless we've got something to match
// against and we're told to do so.
if (filePaths != null && explicitPathsOptions != null)
{