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

Re: tracking repository

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2008, 00:35 UTC
Message-ID
<7vlk4ichm4.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LNX.1.00.0803161716470.19665@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
> We don't currently have any concept of an invalid refspec;
We don't? or just that parse_ref_spec() does not detect one?
> ... 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).
I am afraid that is an invitation for more bugs and confusions.

It probably is not too late to fix this; users would rather want to see their misconfigurations clearly flagged as such, rather than the code letting bogosity through silently and doing something that does not exactly match what they configured.

Show 13 quoted lines
> 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;

How would this trigger? We find * (or /*) but that is the one on the LHS, which means the spec was like "refs/heads/foobar:refs/remotes/origin/*", and it makes me wonder if we should mark this as an configuration error.

Did erroring out on "gp && ep && gp > ep" here have issues (i.e. reject a valid configuration)?

Show 10 quoted lines
>  		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);

This truncates "refs/heads/*:refs/remotes/origin/*/bar" as if it did not have "/bar" without any error indication. The same questions apply.

Previous: Junio C HamanoNext: Daniel Barkalow
Message 12 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.