Merge pull request #3862 from novalis/dturner/do-not-die-on-missing-config

remote: Handle missing config values when deleting a remote
This commit is contained in:
Edward Thomson 2016-07-24 15:51:13 -04:00 committed by GitHub
commit 76cfdd4612
2 changed files with 13 additions and 4 deletions

View File

@ -10,6 +10,9 @@ v0.24 + 1
directory matching the starting directory will not prevent git from directory matching the starting directory will not prevent git from
finding a repository in the starting directory or a parent directory. finding a repository in the starting directory or a parent directory.
* Do not fail when deleting remotes in the presence of broken
global configs which contain branches.
### API additions ### API additions
* You can now get the user-agent used by libgit2 using the * You can now get the user-agent used by libgit2 using the

View File

@ -2162,15 +2162,21 @@ static int remove_branch_config_related_entries(
if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0) if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0)
break; break;
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
break; if (error != GIT_ENOTFOUND)
break;
giterr_clear();
}
git_buf_clear(&buf); git_buf_clear(&buf);
if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0) if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0)
break; break;
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
break; if (error != GIT_ENOTFOUND)
break;
giterr_clear();
}
} }
if (error == GIT_ITEROVER) if (error == GIT_ITEROVER)