diff options
author | yuangli <yuangli@mathworks.com> | 2022-07-11 15:25:51 +0100 |
---|---|---|
committer | yuangli <yuangli@mathworks.com> | 2022-07-11 15:25:51 +0100 |
commit | 7560ac4d2f19906729963cbdf7c8c7fb675b8f8a (patch) | |
tree | 1eeb84eef3eb53e878f8779de09c1e40eccc9997 | |
parent | 724b5a0e97e54a0cab5422caf4d4244af27bdca7 (diff) | |
download | libgit2-7560ac4d2f19906729963cbdf7c8c7fb675b8f8a.tar.gz |
branches: fix error message for invalid name
-rw-r--r-- | src/branch.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/branch.c b/src/branch.c index 69be8c796..22e7ba82b 100644 --- a/src/branch.c +++ b/src/branch.c @@ -54,6 +54,12 @@ static int not_a_local_branch(const char *reference_name) static bool branch_name_follows_pattern(const char *branch_name) { + /* + * Discourage branch name starting with dash, + * https://github.com/git/git/commit/6348624010888b + * and discourage HEAD as branch name, + * https://github.com/git/git/commit/a625b092cc5994 + */ return branch_name[0] != '-' && git__strcmp(branch_name, "HEAD"); } @@ -78,7 +84,7 @@ static int create_branch( GIT_ASSERT_ARG(git_commit_owner(commit) == repository); if (!branch_name_follows_pattern(branch_name)) { - git_error_set(GIT_ERROR_REFERENCE, "'HEAD' is not a valid branch name"); + git_error_set(GIT_ERROR_REFERENCE, "'%s' is not a valid branch name", branch_name); error = -1; goto cleanup; } @@ -761,12 +767,6 @@ int git_branch_name_is_valid(int *valid, const char *name) *valid = 0; - /* - * Discourage branch name starting with dash, - * https://github.com/git/git/commit/6348624010888b - * and discourage HEAD as branch name, - * https://github.com/git/git/commit/a625b092cc5994 - */ if (!name || !branch_name_follows_pattern(name)) goto done; |