-
Notifications
You must be signed in to change notification settings - Fork 899
repo.Network.Remotes.Remove does not remove the remote #1437
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
Comments
I have the same issue. It does remove
|
Thanks for reporting this and @arutkowski00 for the helpful clarification. We'll take a look. |
The section header should be irrelevant for the existence of the remote. A remote does not exist because the header exists. Not removing the header is just a cosmetic bug because we do not remove entire sections but individual configuration entries. What is the state of the config file when this error occurs? Is there concurrent access that might stop us from modifying the file (assuming you're on Windows). |
@carlosmn We always synchronize call to git operation (so no concurrent access). As for file may not be writable, we are sure it was since calling git remote remove origin successfully remove it. Unfortunately, we did not capture the state of the config file - will do once it repro-ed again. |
I can still reproduce this with 0.31.0. Repro stepsStep 1: Create a new repo with Step 2: Add a remote: Step 3: Run the following code: using LibGit2Sharp;
var repo = new Repository(".");
LogRemotes("Initial");
repo.Network.Remotes.Add("test", "https://bogus");
LogRemotes("After adding");
repo.Network.Remotes.Remove("test");
LogRemotes("After removing");
void LogRemotes(string description)
{
Console.WriteLine(description);
foreach (var remote in repo.Network.Remotes)
{
Console.WriteLine($"{remote.Name}: {remote.Url}");
}
Console.WriteLine();
} Step 4: Repro outputStep 3 - this looks okay
Step 4 - this is broken:
The empty |
We have this code below where we remove remote (origin) before adding a new one. From time to time, Add would fail with remote already exists. Is there an issue where remote is not removed when calling repo.Network.Remotes.Remove? Is it a race condition? We doubt it is since rerun the same code still yield remote already exists. Anything we do wrong or can improve? BTW, if we run git remote remove origin command, then it is removed - so repo is not corrupted.
The text was updated successfully, but these errors were encountered: