Skip to content

Commit f3c998c

Browse files
committed
Merge pull request #1283 from libgit2/no-diff-notify-unless-necessary
Don't provide a diff notify callback unless necessary
2 parents 2994bcf + 32f6cca commit f3c998c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

LibGit2Sharp/Diff.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,25 @@ private DiffHandle BuildDiffList(
516516
ExplicitPathsOptions explicitPathsOptions,
517517
CompareOptions compareOptions)
518518
{
519-
var matchedPaths = new MatchedPathsAggregator();
520519
var filePaths = repo.ToFilePaths(paths);
521520

521+
MatchedPathsAggregator matchedPaths = null;
522+
523+
// We can't match paths unless we've got something to match
524+
// against and we're told to do so.
525+
if (filePaths != null && explicitPathsOptions != null)
526+
{
527+
if (explicitPathsOptions.OnUnmatchedPath != null || explicitPathsOptions.ShouldFailOnUnmatchedPath)
528+
{
529+
matchedPaths = new MatchedPathsAggregator();
530+
}
531+
}
532+
522533
using (GitDiffOptions options = BuildOptions(diffOptions, filePaths, matchedPaths, compareOptions))
523534
{
524535
var diffList = comparisonHandleRetriever(oldTreeId, newTreeId, options);
525536

526-
if (explicitPathsOptions != null)
537+
if (matchedPaths != null)
527538
{
528539
try
529540
{

0 commit comments

Comments
 (0)