summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-04-02 10:31:55 +0100
committerGitHub <noreply@github.com>2021-04-02 10:31:55 +0100
commit34b9a04c77235dfc9401cb7ef8efc6c4ee7e99dd (patch)
tree4099cfdfdbda376f6e09bda733b1e012c496b80b /src
parent508361401fbb5d87118045eaeae3356a729131aa (diff)
parent7891e15375e1f9737f8e6a348fae36f0d6f5c2f6 (diff)
downloadlibgit2-34b9a04c77235dfc9401cb7ef8efc6c4ee7e99dd.tar.gz
Merge pull request #5832 from ianhattendorf/fix/repo-is-empty-empty-config-defaultbranch
Default to GIT_BRANCH_DEFAULT if init.defaultBranch is empty string
Diffstat (limited to 'src')
-rw-r--r--src/repository.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/repository.c b/src/repository.c
index de1a89582..2c8b8192e 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2384,10 +2384,11 @@ int git_repository_initialbranch(git_buf *out, git_repository *repo)
if ((error = git_repository_config__weakptr(&config, repo)) < 0)
return error;
- if ((error = git_config_get_entry(&entry, config, "init.defaultbranch")) == 0) {
+ if ((error = git_config_get_entry(&entry, config, "init.defaultbranch")) == 0 &&
+ *entry->value) {
branch = entry->value;
}
- else if (error == GIT_ENOTFOUND) {
+ else if (!error || error == GIT_ENOTFOUND) {
branch = GIT_BRANCH_DEFAULT;
}
else {