diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-05-02 23:00:08 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-05-20 15:50:56 +0400 |
commit | 2054391b299149f06fceadea357ffe8ceb395e87 (patch) | |
tree | 76a1160b2bf9dfc42d1c92e8f0504aa3fcec1d08 /LibGit2Sharp/Diff.cs | |
parent | 40bf30eae534d803173217d98d317fef21969685 (diff) |
Make Diff.Compare able to handle a blob to blob comparison
Diffstat (limited to 'LibGit2Sharp/Diff.cs')
-rw-r--r-- | LibGit2Sharp/Diff.cs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs index 9c4dbc18..c216fdcc 100644 --- a/LibGit2Sharp/Diff.cs +++ b/LibGit2Sharp/Diff.cs @@ -12,13 +12,15 @@ namespace LibGit2Sharp { private readonly Repository repo; + internal static GitDiffOptions DefaultOptions = new GitDiffOptions { InterhunkLines = 2 }; + internal Diff(Repository repo) { this.repo = repo; } /// <summary> - /// Show changes between two trees. + /// Show changes between two <see cref = "Tree"/>s. /// </summary> /// <param name = "oldTree">The <see cref = "Tree"/> you want to compare from.</param> /// <param name = "newTree">The <see cref = "Tree"/> you want to compare to.</param> @@ -37,16 +39,22 @@ namespace LibGit2Sharp using (var osw2 = new ObjectSafeWrapper(newTree, repo)) { DiffListSafeHandle diff; - GitDiffOptions options = BuildDefaultOptions(); + GitDiffOptions options = DefaultOptions; Ensure.Success(NativeMethods.git_diff_tree_to_tree(repo.Handle, options, osw1.ObjectPtr, osw2.ObjectPtr, out diff)); return diff; } } - private GitDiffOptions BuildDefaultOptions() + /// <summary> + /// Show changes between two <see cref = "Blob"/>s. + /// </summary> + /// <param name = "oldBlob">The <see cref = "Blob"/> you want to compare from.</param> + /// <param name = "newBlob">The <see cref = "Blob"/> you want to compare to.</param> + /// <returns>A <see cref = "ContentChanges"/> containing the changes between the <paramref name = "oldBlob"/> and the <paramref name = "newBlob"/>.</returns> + public ContentChanges Compare(Blob oldBlob, Blob newBlob) { - return new GitDiffOptions { InterhunkLines = 2 }; + return new ContentChanges(repo, oldBlob, newBlob, DefaultOptions); } } } |