Skip to content

Commit 76cfdd4

Browse files
author
Edward Thomson
authored
Merge pull request libgit2#3862 from novalis/dturner/do-not-die-on-missing-config
remote: Handle missing config values when deleting a remote
2 parents 378d12a + d81cb2e commit 76cfdd4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ v0.24 + 1
1010
directory matching the starting directory will not prevent git from
1111
finding a repository in the starting directory or a parent directory.
1212

13+
* Do not fail when deleting remotes in the presence of broken
14+
global configs which contain branches.
15+
1316
### API additions
1417

1518
* You can now get the user-agent used by libgit2 using the

src/remote.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,15 +2162,21 @@ static int remove_branch_config_related_entries(
21622162
if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0)
21632163
break;
21642164

2165-
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0)
2166-
break;
2165+
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
2166+
if (error != GIT_ENOTFOUND)
2167+
break;
2168+
giterr_clear();
2169+
}
21672170

21682171
git_buf_clear(&buf);
21692172
if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0)
21702173
break;
21712174

2172-
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0)
2173-
break;
2175+
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
2176+
if (error != GIT_ENOTFOUND)
2177+
break;
2178+
giterr_clear();
2179+
}
21742180
}
21752181

21762182
if (error == GIT_ITEROVER)

0 commit comments

Comments
 (0)