diff options
author | nulltoken <emeric.fermas@gmail.com> | 2015-05-23 12:38:52 +0300 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2015-05-23 14:46:35 +0300 |
commit | 66c41b3329bf36860c1df9f6318d5cef3b8caf8f (patch) | |
tree | 57996c418d90efd803215bbe70503c001dfd30a0 | |
parent | abdc1c55f045a9e10252c5de5af4ab3e4f9ef9db (diff) |
Obsolete CompareOptions.UsePatienceAlgorithm in favor of .Algorithm
Fix #1043
-rw-r--r-- | LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs | 2 | ||||
-rw-r--r-- | LibGit2Sharp/CompareOptions.cs | 10 | ||||
-rw-r--r-- | LibGit2Sharp/Diff.cs | 2 | ||||
-rw-r--r-- | LibGit2Sharp/DiffAlgorithm.cs | 18 | ||||
-rw-r--r-- | LibGit2Sharp/LibGit2Sharp.csproj | 1 |
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" /> |