-
Notifications
You must be signed in to change notification settings - Fork 899
Introduce RemoteCollection.Remove() #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
using (ThreadAffinity()) | ||
{ | ||
int res = NativeMethods.git_remote_delete(remote); | ||
Ensure.ZeroResult(res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that git_branch_delete has SetHandleAsInvalid before ZeroResult.
Does the order matter for code consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the git_remote_delete()
implementation, I think your code construct is better.
if res < 0, we'll throw and the handle will be freed by the surrounding using statement.
I think git_branch_delete() should be fixed and follow the same pattern if the call to free() is the last line in libgit2 code.
I guess it should be fine now. |
{ | ||
using (ThreadAffinity()) | ||
{ | ||
RemoteSafeHandle remote = Proxy.git_remote_load(repo, name, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like this?
RemoteSafeHandle remote = null;
try
{
remote = Proxy.git_remote_load(repo, name, false);
if (remote == null)
{
return;
}
int res = NativeMethods.git_remote_delete(remote);
Ensure.ZeroResult(res);
remote.SetHandleAsInvalid();
}
finally
{
handle.SafeDispose();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, didn't find SafeDispose before. :O
Also, on a side note: I'm on a Mono machine atm, and since the build fails with my current Mono, I'd rather see travis tell me if it builds or not. I'm dry-coding atm. |
Woot, I need to find a way to get the refs, and not being able to build is a pain since I can't debug. Either this, or wait 2 hours so I get home. |
repo exposes a |
The test fails because the |
Yeah for integration testing! |
Permission to bump native libs? |
👍 |
using (var repo = new Repository(path)) | ||
{ | ||
Assert.NotNull(repo.Network.Remotes["origin"]); | ||
Assert.NotNull(repo.Refs["refs/remotes/origin/test"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it, how would you feel about going on step further and check all the refs from this remote?
Assert.NotEmpty(repo.Refs.FromGlob("refs/remotes/origin/*"));
repo.Network.Remotes.Remove("origin");
Assert.Null(repo.Network.Remotes["origin"]);
Assert.Empty(repo.Refs.FromGlob("refs/remotes/origin/*"));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kay. :D
Done, waiting on build. |
🎱 |
closes #729