Skip to content

Commit dac529e

Browse files
mhaggergitster
authored andcommitted
check_refname_component(): return 0 for zero-length components
Return 0 (instead of -1) for zero-length components. Move the interpretation of zero-length components as illegal to check_refname_format(). This will make it easier to extend check_refname_format() to also check whether directory names are valid. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 732134e commit dac529e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

refs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int check_refname_component(const char *refname, int flags)
5151
last = ch;
5252
}
5353
if (cp == refname)
54-
return -1; /* Component has zero length. */
54+
return 0; /* Component has zero length. */
5555
if (refname[0] == '.') {
5656
if (!(flags & REFNAME_DOT_COMPONENT))
5757
return -1; /* Component starts with '.'. */
@@ -74,7 +74,7 @@ int check_refname_format(const char *refname, int flags)
7474
while (1) {
7575
/* We are at the start of a path component. */
7676
component_len = check_refname_component(refname, flags);
77-
if (component_len < 0) {
77+
if (component_len <= 0) {
7878
if ((flags & REFNAME_REFSPEC_PATTERN) &&
7979
refname[0] == '*' &&
8080
(refname[1] == '\0' || refname[1] == '/')) {

0 commit comments

Comments
 (0)