refs: move ref name helpers around

strbuf_branchname(), strbuf_check_{branch,tag}_ref() are helper
functions to deal with branch and tag names, and the fact that they
happen to use strbuf to hold the name of a branch or a tag is not
essential.  These functions fit better in the refs API than strbuf
API, the latter of which is about string manipulations.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2024-12-03 11:32:37 +09:00
parent 92999a42db
commit 5bcbde9e49
5 changed files with 76 additions and 69 deletions

View File

@@ -447,17 +447,6 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
return 0;
}
static int strbuf_check_tag_ref(struct strbuf *sb, const char *name)
{
if (name[0] == '-')
return -1;
strbuf_reset(sb);
strbuf_addf(sb, "refs/tags/%s", name);
return check_refname_format(sb->buf, 0);
}
int cmd_tag(int argc,
const char **argv,
const char *prefix,