Re: tracking repository

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: tracking repository

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:23

kenneth johansson [off-list ref] 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.

Once we fix that regression, the above would stop working (in)correctly.
Rewrite it to something like this right now will make it keep working:

 	fetch = +refs/heads/*:refs/heads/stable_2.6.12/*

Re: tracking repository

From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:44:23

On Sun, 16 Mar 2008, Junio C Hamano wrote:
kenneth johansson [off-list ref] writes:
quoted
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 [off-list ref]
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 [off-list ref]
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);
 	}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help