Skip to content

Commit

Permalink
refs: ensure multi-level refnames begin with "refs/"
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Wood <[email protected]>
  • Loading branch information
phillipwood committed Nov 15, 2023
1 parent cfb8a6e commit c729010
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/');
Expand Down

0 comments on commit c729010

Please sign in to comment.