Re: [PATCH 4/4] remote: check branch names
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 18, 2024, 20:24 UTC
- Message-ID
- <xmqqh6acbti0.fsf@gitster.g>
- In-Reply-To
- <82a08e44-3822-4a26-ad09-4ca1a9b44c11@gmail.com>
phillip.wood123@gmail.com writes:
Show 10 quoted lines
> ... Given that "git remote
> set-branches" has only ever supported "real" branch names and patterns
> on the command line and no-one has complained I wonder if we're better
> off doing something like
>
> if (strbuf_check_branch_ref(&buf, branch_name) ||
> strcmp(buf.buf + 11, branch_name))
> error(_("invalid branch name '%s'", branch_name));
>
> where the "buf.buf + 11" skips "refs/heads/"Yeah, replacing +11 with skip_prefix() or something for readability, such a check might be good enough in pracrice.
Thanks.