git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Petr Baudis <pasky@suse.cz>
Cc: Alex Riesen <raa.lkml@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] [COGITO] make cg-tag use git-check-ref-format
Date: Thu, 15 Dec 2005 18:17:19 -0800	[thread overview]
Message-ID: <7virtplr9s.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vacf2lyn4.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Thu, 15 Dec 2005 15:38:07 -0800")

Junio C Hamano <junkio@cox.net> writes:

> The wildcard letters like ? and * I understand and sympathetic
> about somewhat.  Something like this:
>
>         name="*.sh" ;# this also comes from the end user
>         echo $name
>
> ends up showing every shell script in the current directory,
> and not literal '*.sh'.

So why don't we do this?

-- >8 --
Subject: [PATCH] Forbid pattern maching characters in refnames.

by marking '?', '*', and '[' as bad_ref_char().

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 Documentation/git-check-ref-format.txt |    8 +++++---
 refs.c                                 |    4 +++-
 2 files changed, 8 insertions(+), 4 deletions(-)

d04ec25a77249095b6d2af5a08fe131351f2d86d
diff --git a/Documentation/git-check-ref-format.txt b/Documentation/git-check-ref-format.txt
index 636e951..f7f84c6 100644
--- a/Documentation/git-check-ref-format.txt
+++ b/Documentation/git-check-ref-format.txt
@@ -26,13 +26,15 @@ imposes the following rules on how refs 
 
 . It cannot have ASCII control character (i.e. bytes whose
   values are lower than \040, or \177 `DEL`), space, tilde `~`,
-  caret `{caret}`, or colon `:` anywhere;
+  caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`,
+  or open bracket `[` anywhere;
 
 . It cannot end with a slash `/`.
 
 These rules makes it easy for shell script based tools to parse
-refnames, and also avoids ambiguities in certain refname
-expressions (see gitlink:git-rev-parse[1]).  Namely:
+refnames, pathname expansion by the shell when a refname is used
+unquoted (by mistake), and also avoids ambiguities in certain
+refname expressions (see gitlink:git-rev-parse[1]).  Namely:
 
 . double-dot `..` are often used as in `ref1..ref2`, and in some
   context this notation means `{caret}ref1 ref2` (i.e. not in
diff --git a/refs.c b/refs.c
index b8fcb98..0d63c1f 100644
--- a/refs.c
+++ b/refs.c
@@ -313,7 +313,9 @@ int write_ref_sha1(const char *ref, int 
 static inline int bad_ref_char(int ch)
 {
 	return (((unsigned) ch) <= ' ' ||
-		ch == '~' || ch == '^' || ch == ':');
+		ch == '~' || ch == '^' || ch == ':' ||
+		/* 2.13 Pattern Matching Notation */
+		ch == '?' || ch == '*' || ch == '[');
 }
 
 int check_ref_format(const char *ref)
-- 
0.99.9.GIT

  reply	other threads:[~2005-12-16  2:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-13 10:54 [PATCH] [COGITO] make cg-tag use git-check-ref-format Martin Atukunda
2005-12-13 11:13 ` Junio C Hamano
2005-12-13 11:28   ` Martin Atukunda
2005-12-13 17:00   ` Petr Baudis
2005-12-13 18:41     ` Junio C Hamano
2005-12-15 22:24       ` Alex Riesen
2005-12-15 23:38         ` Junio C Hamano
2005-12-16  2:17           ` Junio C Hamano [this message]
2005-12-16  9:17             ` Petr Baudis

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=7virtplr9s.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=pasky@suse.cz \
    --cc=raa.lkml@gmail.com \
    /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).