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

[RFC 2/7] check_refname_component(): fix check with REFNAME_DOT_COMPONENT

From
mhagger@alum.mit.edu <mhagger@alum.mit.edu>
Date
Apr 30, 2012, 23:02 UTC
Message-ID
<1335826975-3093-3-git-send-email-mhagger@alum.mit.edu>
In-Reply-To
<1335826975-3093-1-git-send-email-mhagger@alum.mit.edu>
From: Michael Haggerty <mhagger@alum.mit.edu>

When REFNAME_DOT_COMPONENT is set, we want to allow refname components that start with '.' but not equal to ".". The old code would have allowed refname components equal to "." if they were not the last component of the refname. Fix the test.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 refs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/refs.c b/refs.c
index 927d36c..c293fd2 100644
--- a/refs.c
+++ b/refs.c
@@ -59,7 +59,7 @@ static int check_refname_component(const char *refname, int flags)
 		 * Even if leading dots are allowed, don't allow "."
 		 * as a component (".." is prevented by a rule above).
 		 */
-		if (len == 1)
+		if (i == 1)
 			return -1; /* Component equals ".". */
 	}
 	if (i >= 5 && !memcmp(&refname[i - 5], ".lock", 5))
-- 
1.7.10
Previous: mhagger@alum.mit.eduNext: mhagger@alum.mit.edu
Message 3 of 8 in “[RFC 0/7] Make check_refname_format() more flexible”
  1. mhagger@alum.mit.eduApr 30, 2012
  2. 1/7 check_refname_component(): iterate via index rather than via pointermhagger@alum.mit.edu, Apr 30, 2012
  3. 2/7 check_refname_component(): fix check with REFNAME_DOT_COMPONENTmhagger@alum.mit.edu, Apr 30, 2012
  4. 3/7 parse_refname_component(): accept a length parametermhagger@alum.mit.edu, Apr 30, 2012
  5. 4/7 parse_refname_component(): parse until terminatormhagger@alum.mit.edu, Apr 30, 2012
  6. 5/7 parse_refname_prefix(): new functionmhagger@alum.mit.edu, Apr 30, 2012
  7. 6/7 check_refname_format(): add REFNAME_FULL optionmhagger@alum.mit.edu, Apr 30, 2012
  8. 7/7 check_refname_format(): implement REFNAME_RELAXED optionmhagger@alum.mit.edu, Apr 30, 2012

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.