Skip to content

Commit 89ce631

Browse files
committed
Merge pull request #1284 from libgit2/dispose-of-remotes
Eagerly dispose of Remotes
2 parents f3c998c + 7c23331 commit 89ce631

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

LibGit2Sharp/BranchUpdater.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private void SetUpstreamRemote(string remoteName)
154154
if (!remoteName.Equals(".", StringComparison.Ordinal))
155155
{
156156
// Verify that remote exists.
157-
repo.Network.Remotes.RemoteForName(remoteName);
157+
using (repo.Network.Remotes.RemoteForName(remoteName)) { }
158158
}
159159

160160
repo.Config.Set(configKey, remoteName);
@@ -183,8 +183,10 @@ private void GetUpstreamInformation(string canonicalName, out string remoteName,
183183
{
184184
remoteName = Proxy.git_branch_remote_name(repo.Handle, canonicalName, true);
185185

186-
Remote remote = repo.Network.Remotes.RemoteForName(remoteName);
187-
mergeBranchName = remote.FetchSpecTransformToSource(canonicalName);
186+
using (var remote = repo.Network.Remotes.RemoteForName(remoteName))
187+
{
188+
mergeBranchName = remote.FetchSpecTransformToSource(canonicalName);
189+
}
188190
}
189191
else
190192
{

0 commit comments

Comments
 (0)