summaryrefslogtreecommitdiff
path: root/src/repository.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-10-11 13:20:52 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2020-10-25 16:33:27 +0000
commitb52bb4d4b2548d0c7f00de0eab5073cc8fe9e899 (patch)
tree89b5bc95613013bc79e922ad7de85135dbcbd534 /src/repository.c
parent29715d4082ef97d54ce2bf24943425f558335796 (diff)
downloadlibgit2-b52bb4d4b2548d0c7f00de0eab5073cc8fe9e899.tar.gz
refs: use git_reference_name_is_valid
Diffstat (limited to 'src/repository.c')
-rw-r--r--src/repository.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/repository.c b/src/repository.c
index 513dbd61f..f0d4b06aa 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2359,7 +2359,7 @@ int git_repository_initialbranch(git_buf *out, git_repository *repo)
git_config *config;
git_config_entry *entry = NULL;
const char *branch;
- int error;
+ int valid, error;
if ((error = git_repository_config__weakptr(&config, repo)) < 0)
return error;
@@ -2375,10 +2375,11 @@ int git_repository_initialbranch(git_buf *out, git_repository *repo)
}
if ((error = git_buf_puts(out, GIT_REFS_HEADS_DIR)) < 0 ||
- (error = git_buf_puts(out, branch)) < 0)
+ (error = git_buf_puts(out, branch)) < 0 ||
+ (error = git_reference_name_is_valid(&valid, out->ptr)) < 0)
goto done;
- if (!git_reference_is_valid_name(out->ptr)) {
+ if (!valid) {
git_error_set(GIT_ERROR_INVALID, "the value of init.defaultBranch is not a valid reference name");
error = -1;
}