Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2015-05-27 10:28:46 +0300
committernulltoken <emeric.fermas@gmail.com>2015-05-27 10:28:46 +0300
commitef63b095d77622c186927d64a488a00f3cec119e (patch)
treee2f2626b956359daa251354047eba43faf743b07
parent659be882b2445a6273d0cde9781f9a1b42c52648 (diff)
parent66c41b3329bf36860c1df9f6318d5cef3b8caf8f (diff)
Merge pull request #1043 from libgit2/ntk/diff
Expose a more generic DiffAlgorithm property in CompareOptions
-rw-r--r--LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs2
-rw-r--r--LibGit2Sharp/CompareOptions.cs10
-rw-r--r--LibGit2Sharp/Diff.cs2
-rw-r--r--LibGit2Sharp/DiffAlgorithm.cs18
-rw-r--r--LibGit2Sharp/LibGit2Sharp.csproj1
5 files changed, 31 insertions, 2 deletions
diff --git a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs
index 479b39d7..0e8ef905 100644
--- a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs
+++ b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs
@@ -1200,7 +1200,7 @@ namespace LibGit2Sharp.Tests
Assert.Equal(diffDefault, repo.Diff.Compare<Patch>(treeOld, treeNew));
Assert.Equal(diffPatience, repo.Diff.Compare<Patch>(treeOld, treeNew,
- compareOptions: new CompareOptions { UsePatienceAlgorithm = true }));
+ compareOptions: new CompareOptions { Algorithm = DiffAlgorithm.Patience }));
}
}
}
diff --git a/LibGit2Sharp/CompareOptions.cs b/LibGit2Sharp/CompareOptions.cs
index fccd7558..6e9acb43 100644
--- a/LibGit2Sharp/CompareOptions.cs
+++ b/LibGit2Sharp/CompareOptions.cs
@@ -1,3 +1,5 @@
+using System;
+
namespace LibGit2Sharp
{
/// <summary>
@@ -12,6 +14,7 @@ namespace LibGit2Sharp
{
ContextLines = 3;
InterhunkLines = 0;
+ Algorithm = DiffAlgorithm.Meyers;
}
/// <summary>
@@ -39,6 +42,13 @@ namespace LibGit2Sharp
/// <summary>
/// Use the "patience diff" algorithm.
/// </summary>
+ [Obsolete("This property will be removed in the next release. Please use Algorithm instead.")]
public bool UsePatienceAlgorithm { get; set; }
+
+ /// <summary>
+ /// Algorithm to be used when performing a Diff.
+ /// By default, <see cref="DiffAlgorithm.Meyers"/> will be used.
+ /// </summary>
+ public DiffAlgorithm Algorithm { get; set; }
}
}
diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs
index 54ad11b0..265aa0cd 100644
--- a/LibGit2Sharp/Diff.cs
+++ b/LibGit2Sharp/Diff.cs
@@ -49,7 +49,7 @@ namespace LibGit2Sharp
options.Flags |= GitDiffOptionFlags.GIT_DIFF_INCLUDE_UNMODIFIED;
}
- if (compareOptions.UsePatienceAlgorithm)
+ if (compareOptions.Algorithm == DiffAlgorithm.Patience)
{
options.Flags |= GitDiffOptionFlags.GIT_DIFF_PATIENCE;
}
diff --git a/LibGit2Sharp/DiffAlgorithm.cs b/LibGit2Sharp/DiffAlgorithm.cs
new file mode 100644
index 00000000..9e89e68e
--- /dev/null
+++ b/LibGit2Sharp/DiffAlgorithm.cs
@@ -0,0 +1,18 @@
+namespace LibGit2Sharp
+{
+ /// <summary>
+ /// Algorithm used when performing a Diff.
+ /// </summary>
+ public enum DiffAlgorithm
+ {
+ /// <summary>
+ /// The basic greedy diff algorithm.
+ /// </summary>
+ Meyers = 0,
+
+ /// <summary>
+ /// Use "patience diff" algorithm when generating patches.
+ /// </summary>
+ Patience = 2,
+ }
+}
diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj
index 856d2433..1b630e57 100644
--- a/LibGit2Sharp/LibGit2Sharp.csproj
+++ b/LibGit2Sharp/LibGit2Sharp.csproj
@@ -79,6 +79,7 @@
<Compile Include="Core\Handles\DescribeResultSafeHandle.cs" />
<Compile Include="Core\Handles\IndexNameEntrySafeHandle.cs" />
<Compile Include="Core\Handles\IndexReucEntrySafeHandle.cs" />
+ <Compile Include="DiffAlgorithm.cs" />
<Compile Include="EntryExistsException.cs" />
<Compile Include="FetchOptionsBase.cs" />
<Compile Include="LogEntry.cs" />