Skip to content

Commit a5230d2

Browse files
committed
Remove old using statements from when Diff.cs owned the diff handle
1 parent 0fdb283 commit a5230d2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

LibGit2Sharp/Diff.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,17 @@ public virtual T Compare<T>(Tree oldTree, DiffTargets diffTargets, IEnumerable<s
350350
}
351351
}
352352

353-
using (DiffSafeHandle diff = BuildDiffList(oldTreeId, null, comparer, diffOptions, paths, explicitPathsOptions, compareOptions))
353+
DiffSafeHandle diff = BuildDiffList(oldTreeId, null, comparer, diffOptions, paths, explicitPathsOptions, compareOptions);
354+
355+
try
354356
{
355357
return BuildDiffResult<T>(diff);
356358
}
359+
catch
360+
{
361+
diff.SafeDispose();
362+
throw;
363+
}
357364
}
358365

359366
/// <summary>
@@ -469,10 +476,17 @@ internal virtual T Compare<T>(
469476
}
470477
}
471478

472-
using (DiffSafeHandle diff = BuildDiffList(null, null, comparer, diffOptions, paths, explicitPathsOptions, compareOptions))
479+
DiffSafeHandle diff = BuildDiffList(null, null, comparer, diffOptions, paths, explicitPathsOptions, compareOptions);
480+
481+
try
473482
{
474483
return BuildDiffResult<T>(diff);
475484
}
485+
catch
486+
{
487+
diff.SafeDispose();
488+
throw;
489+
}
476490
}
477491

478492
internal delegate DiffSafeHandle TreeComparisonHandleRetriever(ObjectId oldTreeId, ObjectId newTreeId, GitDiffOptions options);

0 commit comments

Comments
 (0)