Expose diff whitespace settings by darthkurak · Pull Request #2007 · libgit2/libgit2sharp · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions LibGit2Sharp/CompareOptions.cs
18 changes: 17 additions & 1 deletion LibGit2Sharp/Diff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Comment on lines +61 to +75

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought:

Suggested change


if (diffOptions.HasFlag(DiffModifiers.DisablePathspecMatch))
{
options.Flags |= GitDiffOptionFlags.GIT_DIFF_DISABLE_PATHSPEC_MATCH;
Expand Down Expand Up @@ -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)
{
Expand Down