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

Re: [PATCH] [COGITO] make cg-tag use git-check-ref-format

From
Junio C Hamano <junkio@cox.net>
Date
Dec 16, 2005, 02:17 UTC
Message-ID
<7virtplr9s.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vacf2lyn4.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 8 quoted lines
> 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
Previous: Junio C HamanoNext: Petr Baudis
Message 8 of 9 in “[COGITO] make cg-tag use git-check-ref-format”
  1. [COGITO] make cg-tag use git-check-ref-formatMartin Atukunda, Dec 13, 2005
  2. Junio C HamanoDec 13, 2005
  3. Martin AtukundaDec 13, 2005
  4. Petr BaudisDec 13, 2005
  5. Junio C HamanoDec 13, 2005
  6. Alex RiesenDec 15, 2005
  7. Junio C HamanoDec 15, 2005
  8. Junio C HamanoDec 16, 2005
  9. Petr BaudisDec 16, 2005

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.