Skip to content

Commit 48a8b45

Browse files
committed
refs: use is_root_ref_syntax() in refname_is_safe()
The open-coded logic in refname_is_safe() predates the addition of is_root_ref_syntax(). But now that we have it, we can make use of it. This shortens the code, but also makes sure we use a consistent definition of the syntax. Signed-off-by: Jeff King <peff@peff.net>
1 parent 54a6fea commit 48a8b45

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

refs.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref)
170170
info->ref_updated = 1;
171171
}
172172

173+
static int is_root_ref_syntax(const char *refname);
174+
173175
/*
174176
* Try to read one refname component from the front of refname.
175177
* Return the length of the component found, or -1 if the component is
@@ -404,12 +406,7 @@ int refname_is_safe(const char *refname)
404406
return result;
405407
}
406408

407-
do {
408-
if (!isupper(*refname) && *refname != '_')
409-
return 0;
410-
refname++;
411-
} while (*refname);
412-
return 1;
409+
return is_root_ref_syntax(refname);
413410
}
414411

415412
/*

0 commit comments

Comments
 (0)