diff options
author | nulltoken <emeric.fermas@gmail.com> | 2014-05-31 21:57:30 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2014-06-02 21:36:29 +0400 |
commit | 580dee60f05497812a7d788147b74052181c9f55 (patch) | |
tree | af9b444ffdb0ee58de28ec05e831cbc027663856 /LibGit2Sharp/Diff.cs | |
parent | 8384e7eb62c48a219f0a9acd0de1d75cc0773724 (diff) |
Simplify disposal of some resources
Diffstat (limited to 'LibGit2Sharp/Diff.cs')
-rw-r--r-- | LibGit2Sharp/Diff.cs | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs index b276ebc3..6f0191e7 100644 --- a/LibGit2Sharp/Diff.cs +++ b/LibGit2Sharp/Diff.cs @@ -292,23 +292,12 @@ namespace LibGit2Sharp { TreeComparisonHandleRetriever comparisonHandleRetriever = (oh, nh, o) => { - DiffSafeHandle diff = null, diff2 = null; + DiffSafeHandle diff = Proxy.git_diff_tree_to_index(repo.Handle, repo.Index.Handle, oh, o); - try + using (DiffSafeHandle diff2 = Proxy.git_diff_index_to_workdir(repo.Handle, repo.Index.Handle, o)) { - diff = Proxy.git_diff_tree_to_index(repo.Handle, repo.Index.Handle, oh, o); - diff2 = Proxy.git_diff_index_to_workdir(repo.Handle, repo.Index.Handle, o); Proxy.git_diff_merge(diff, diff2); } - catch - { - diff.SafeDispose(); - throw; - } - finally - { - diff2.SafeDispose(); - } return diff; }; @@ -332,17 +321,9 @@ namespace LibGit2Sharp { var diffList = comparisonHandleRetriever(oldTreeId, newTreeId, options); - try - { - if (explicitPathsOptions != null) - { - DispatchUnmatchedPaths(explicitPathsOptions, filePaths, matchedPaths); - } - } - catch + if (explicitPathsOptions != null) { - diffList.Dispose(); - throw; + DispatchUnmatchedPaths(explicitPathsOptions, filePaths, matchedPaths); } DetectRenames(diffList, compareOptions); |