Skip to content

Commit 7560ac4

Browse files
author
yuangli
committed
branches: fix error message for invalid name
1 parent 724b5a0 commit 7560ac4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/branch.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ static int not_a_local_branch(const char *reference_name)
5454

5555
static bool branch_name_follows_pattern(const char *branch_name)
5656
{
57+
/*
58+
* Discourage branch name starting with dash,
59+
* https://github.com/git/git/commit/6348624010888b
60+
* and discourage HEAD as branch name,
61+
* https://github.com/git/git/commit/a625b092cc5994
62+
*/
5763
return branch_name[0] != '-' && git__strcmp(branch_name, "HEAD");
5864
}
5965

@@ -78,7 +84,7 @@ static int create_branch(
7884
GIT_ASSERT_ARG(git_commit_owner(commit) == repository);
7985

8086
if (!branch_name_follows_pattern(branch_name)) {
81-
git_error_set(GIT_ERROR_REFERENCE, "'HEAD' is not a valid branch name");
87+
git_error_set(GIT_ERROR_REFERENCE, "'%s' is not a valid branch name", branch_name);
8288
error = -1;
8389
goto cleanup;
8490
}
@@ -761,12 +767,6 @@ int git_branch_name_is_valid(int *valid, const char *name)
761767

762768
*valid = 0;
763769

764-
/*
765-
* Discourage branch name starting with dash,
766-
* https://github.com/git/git/commit/6348624010888b
767-
* and discourage HEAD as branch name,
768-
* https://github.com/git/git/commit/a625b092cc5994
769-
*/
770770
if (!name || !branch_name_follows_pattern(name))
771771
goto done;
772772

0 commit comments

Comments
 (0)