summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-04-10 07:30:22 +0200
committerJunio C Hamano <gitster@pobox.com>2012-04-10 15:54:58 -0700
commitdac529e44fb9e8c0ee4628c0f947db8890950317 (patch)
treeadf981d10a4dd2d6f536e4d15ab8806c83ab934b /refs.c
parent732134edab1f20a8ce2ef3812a819a2216e9eb88 (diff)
downloadgit-dac529e44fb9e8c0ee4628c0f947db8890950317.tar.gz
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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index 8659c3eff7..1f6890bf48 100644
--- a/refs.c
+++ b/refs.c
@@ -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 '.'. */
@@ -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] == '/')) {