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

Re: tracking repository

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Mar 16, 2008, 21:28 UTC
Message-ID
<alpine.LNX.1.00.0803161716470.19665@iabervon.org>
In-Reply-To
<7vwso2ieuu.fsf@gitster.siamese.dyndns.org>
On Sun, 16 Mar 2008, Junio C Hamano wrote:
Show 13 quoted lines
> kenneth johansson <ken@kenjo.org> writes:
> 
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
> > 	fetch = +refs/heads/*:refs/heads/*
> > [remote "stable_2.6.12"]
> > 	url =
> > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.12.y.git
> > 	fetch = +refs/heads/*:refs/heads/stable_2.6.12_*
> 
> Daniel, I think we are looking at a regression.  The latter style, * at
> the end but not immediately following a slash, should never have worked.
> Wildcard expansion function should be erroring out when it sees something
> like this.
I'm not sure any older code actually enforced this, either

We don't currently have any concept of an invalid refspec; we just have things that fall back to not being patterns and not being possible to match (due to one or the other side being invalid as a ref name).

Here's a patch to make the pattern logic require a slash before the *:
---------
commit 7aa15c359bcfc7a3c87345435b81ef41e1f59800
Author: Daniel Barkalow <barkalow@iabervon.org>
Date:   Sun Mar 16 17:26:41 2008 -0400
    Require / before * in pattern refspecs
    
    We don't want to have "+refs/heads/*:refs/heads/something_*" match
    "refs/heads/master" to "refs/heads/something_master".
    
    Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
diff --git a/remote.c b/remote.c
index f3f7375..fffde34 100644
--- a/remote.c
+++ b/remote.c
@@ -404,18 +404,17 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
 			rs[i].force = 1;
 			sp++;
 		}
-		gp = strchr(sp, '*');
+		gp = strstr(sp, "/*");
 		ep = strchr(sp, ':');
 		if (gp && ep && gp > ep)
 			gp = NULL;
 		if (ep) {
 			if (ep[1]) {
-				const char *glob = strchr(ep + 1, '*');
+				const char *glob = strstr(ep + 1, "/*");
 				if (!glob)
 					gp = NULL;
 				if (gp)
-					rs[i].dst = xstrndup(ep + 1,
-							     glob - ep - 1);
+					rs[i].dst = xstrndup(ep + 1, glob - ep);
 				else
 					rs[i].dst = xstrdup(ep + 1);
 			}
@@ -424,7 +423,7 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
 		}
 		if (gp) {
 			rs[i].pattern = 1;
-			ep = gp;
+			ep = gp + 1;
 		}
 		rs[i].src = xstrndup(sp, ep - sp);
 	}
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 16 in “tracking repository”
  1. kenneth johanssonMar 15, 2008
  2. Junio C HamanoMar 16, 2008
  3. kenneth johanssonMar 16, 2008
  4. Junio C HamanoMar 16, 2008
  5. Daniel BarkalowMar 16, 2008
  6. Junio C HamanoMar 16, 2008
  7. Daniel BarkalowMar 16, 2008
  8. Junio C HamanoMar 16, 2008
  9. Junio C HamanoMar 16, 2008
  10. Daniel BarkalowMar 16, 2008
  11. Junio C HamanoMar 17, 2008
  12. Junio C HamanoMar 17, 2008
  13. Daniel BarkalowMar 17, 2008
  14. Daniel BarkalowMar 17, 2008
  15. Junio C HamanoMar 17, 2008
  16. Daniel BarkalowMar 17, 2008

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.