From: Michael Schubert <mschub@elegosoft.com>
To: git@vger.kernel.org
Cc: Michael Schubert <mschub@elegosoft.com>
Subject: [PATCH 1/2] refs: disallow ref components starting with hyphen
Date: Mon, 16 Jul 2012 14:13:00 +0200 [thread overview]
Message-ID: <1342440781-18816-2-git-send-email-mschub@elegosoft.com> (raw)
In-Reply-To: <1342440781-18816-1-git-send-email-mschub@elegosoft.com>
Currently, we allow refname components to start with a hyphen. There's
no good reason to do so and it troubles the parseopt infrastructure.
Explicitly refuse refname components starting with a hyphen inside
check_refname_component().
Revert 63486240, which is obsolete now.
Signed-off-by: Michael Schubert <mschub@elegosoft.com>
---
builtin/tag.c | 3 ---
refs.c | 2 ++
sha1_name.c | 2 --
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/builtin/tag.c b/builtin/tag.c
index 7b1be85..c99fb42 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -403,9 +403,6 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
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);
diff --git a/refs.c b/refs.c
index da74a2b..5714681 100644
--- a/refs.c
+++ b/refs.c
@@ -62,6 +62,8 @@ static int check_refname_component(const char *refname, int flags)
if (refname[1] == '\0')
return -1; /* Component equals ".". */
}
+ if (refname[0] == '-')
+ return -1; /* Component starts with '-'. */
if (cp - refname >= 5 && !memcmp(cp - 5, ".lock", 5))
return -1; /* Refname ends with ".lock". */
return cp - refname;
diff --git a/sha1_name.c b/sha1_name.c
index 5d81ea0..132d369 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -892,8 +892,6 @@ int strbuf_branchname(struct strbuf *sb, const char *name)
int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
{
strbuf_branchname(sb, name);
- if (name[0] == '-')
- return -1;
strbuf_splice(sb, 0, 0, "refs/heads/", 11);
return check_refname_format(sb->buf, 0);
}
--
1.7.11.2.196.ga22866b
next prev parent reply other threads:[~2012-07-16 12:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-16 12:12 [PATCH] refname format cleanup Michael Schubert
2012-07-16 12:13 ` Michael Schubert [this message]
2012-07-16 13:18 ` [PATCH 1/2] refs: disallow ref components starting with hyphen Michael Haggerty
2012-07-16 17:06 ` Junio C Hamano
2012-07-16 17:49 ` Junio C Hamano
2012-07-16 12:13 ` [PATCH 2/2] symbolic-ref: check format of given refname Michael Schubert
2012-07-16 13:24 ` Michael Haggerty
2012-07-16 17:12 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342440781-18816-2-git-send-email-mschub@elegosoft.com \
--to=mschub@elegosoft.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).