Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Jun 1, 2014
Merged

Conversation

Therzok
Copy link
Member

@Therzok Therzok commented May 30, 2014

closes #729

using (ThreadAffinity())
{
int res = NativeMethods.git_remote_delete(remote);
Ensure.ZeroResult(res);
Copy link
Member Author

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?

Copy link
Member

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.

@Therzok
Copy link
Member Author

Therzok commented May 31, 2014

I guess it should be fine now.

{
using (ThreadAffinity())
{
RemoteSafeHandle remote = Proxy.git_remote_load(repo, name, false);
Copy link
Member

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();
}

Copy link
Member Author

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

@Therzok
Copy link
Member Author

Therzok commented May 31, 2014

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.

@Therzok
Copy link
Member Author

Therzok commented May 31, 2014

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.

@nulltoken
Copy link
Member

Woot, I need to find a way to get the refs,

repo exposes a Refs namespace for this purpose. However, you'll have to provide the full canonical reference name to the indexer (eg. refs/remotes/faraway/branch_name).

@carlosmn
Copy link
Member

The test fails because the refs/remotes/origin/test reference is getting lost in the iterator. This does not happen when we perform a full listing, but only when we remove refrences while iterating, which looks like a bug in libgit2's iterator implementation.

@nulltoken
Copy link
Member

This does not happen when we perform a full listing, but only when we remove refrences while iterating, which looks like a bug in libgit2's iterator implementation.

Yeah for integration testing!

@Therzok
Copy link
Member Author

Therzok commented Jun 1, 2014

Permission to bump native libs?

@nulltoken
Copy link
Member

👍

using (var repo = new Repository(path))
{
Assert.NotNull(repo.Network.Remotes["origin"]);
Assert.NotNull(repo.Refs["refs/remotes/origin/test"]);
Copy link
Member

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/*"));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kay. :D

@Therzok
Copy link
Member Author

Therzok commented Jun 1, 2014

Done, waiting on build.

@nulltoken nulltoken merged commit dcc5c67 into libgit2:vNext Jun 1, 2014
@nulltoken nulltoken added this to the v0.18.0 milestone Jun 1, 2014
@nulltoken
Copy link
Member

🎱 ‼️

@Therzok Therzok deleted the remoteRemove branch June 1, 2014 17:24
@nulltoken nulltoken mentioned this pull request Apr 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants