diff --git a/refs.c b/refs.c index fcae5dddc60506..3997da6f829579 100644 --- a/refs.c +++ b/refs.c @@ -263,6 +263,15 @@ static int check_or_sanitize_refname(const char *refname, int flags, return -1; } + if (!(flags & REFNAME_ALLOW_ONELEVEL) && + !skip_prefix(refname, "refs/", &refname)) { + return -1; + } else if (sanitized) { + if (sanitized->len) + strbuf_complete(sanitized, '/'); + strbuf_addstr(sanitized, "refs/"); + } + while (1) { if (sanitized && sanitized->len) strbuf_complete(sanitized, '/');