git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH] tag: disallow '-' as tag name

From
Junio C Hamano <gitster@pobox.com>
Date
May 9, 2011, 23:08 UTC
Message-ID
<7v62pjo4km.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4DC87113.4030204@elegosoft.com>
Michael Schubert <mschub@elegosoft.com> writes:
> Add strbuf_check_tag_ref() as helper to check a refname for a tag.
>
> Signed-off-by: Michael Schubert <mschub@elegosoft.com>
> ---
That was quick ;-).
Show 15 quoted lines
>  builtin/tag.c |   30 ++++++++++++++++++++++--------
>  1 files changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/builtin/tag.c b/builtin/tag.c
> index b66b34a..f087a7f 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -352,11 +352,26 @@ 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 CHECK_REF_FORMAT_ERROR;

So contrary to what the title claims, it forbids a tag that begins with '-', e.g. '-foo', not just a single dash. That is fine by me (we do the same in strbuf-check-branch-ref) but it needs to be explained better.

> +	strbuf_reset(sb);
> +	strbuf_add(sb, "refs/tags/", 10);
> +	strbuf_add(sb, name, strlen(name));
strbuf_addf(sb, "refs/tags/%s", name)?
> +	if (sb->len > PATH_MAX)
> +		die(_("tag name too long: %.*s..."), 50, name);
I think that should be
	if (PATH_MAX <= sb->len)

but I do not see the point of checking against PATH_MAX if you are already using a strbuf...

Previous: Michael SchubertNext: Michael Schubert
Message 4 of 7 in “Tags named '-'”
  1. Alex VandiverMay 9, 2011
  2. Junio C HamanoMay 9, 2011
  3. tag: disallow '-' as tag nameMichael Schubert, May 9, 2011
  4. Junio C HamanoMay 9, 2011
  5. tag: disallow '-' as tag nameMichael Schubert, May 9, 2011
  6. Sverre RabbelierMay 9, 2011
  7. Michael SchubertMay 10, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.