Skip to content

Commit

Permalink
check_refname_component(): return 0 for zero-length components
Browse files Browse the repository at this point in the history
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 <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Apr 10, 2012
1 parent 732134e commit dac529e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int check_refname_component(const char *refname, int flags)
last = ch;
}
if (cp == refname)
return -1; /* Component has zero length. */
return 0; /* Component has zero length. */
if (refname[0] == '.') {
if (!(flags & REFNAME_DOT_COMPONENT))
return -1; /* Component starts with '.'. */
Expand All @@ -74,7 +74,7 @@ int check_refname_format(const char *refname, int flags)
while (1) {
/* We are at the start of a path component. */
component_len = check_refname_component(refname, flags);
if (component_len < 0) {
if (component_len <= 0) {
if ((flags & REFNAME_REFSPEC_PATTERN) &&
refname[0] == '*' &&
(refname[1] == '\0' || refname[1] == '/')) {
Expand Down

0 comments on commit dac529e

Please sign in to comment.