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

fetch refspec foo/* matches foo*

From
Jeff King <peff@peff.net>
Date
Jul 26, 2008, 08:24 UTC
Message-ID
<20080726082405.GA10104@sigill.intra.peff.net>
In-Reply-To
<7v1w1hsmnc.fsf@gitster.siamese.dyndns.org>
On Fri, Jul 25, 2008 at 02:02:15PM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> BTW, has anybody taken a look at this one?
> 
>   Subject: BUG: fetch incorrect interpretation of globing patterns in refspecs
>   Date: Thu, 24 Jul 2008 09:07:21 +0200
>   Message-ID: <71295b5a0807240007k246973abj1897895d0d67bb6c@mail.gmail.com>
> 
> If not, I think I probably need to take a look at this, reproducing and
> possibly fixing, before applying non-fix patches.

I have been meaning to look at it for days, so I finally took a peek. I was able to reproduce the problem easily. I think it is (almost) as simple as the patch below. In the refspec parsing, we already require globs to come after '/', so this is the analagous check during match.

Unfortunately, this breaks t1020 (something about failing to clone HEAD it looks like, so probably it is some boundary case for matching just "*"). I don't have time to look further, and I will be out of touch until probably Sunday evening, so hopefully somebody else can run with it.

---
diff --git a/remote.c b/remote.c
index 0d6020b..3ae0431 100644
--- a/remote.c
+++ b/remote.c
@@ -1108,7 +1108,8 @@ static struct ref *get_expanded_map(const struct ref *remote_refs,
 	for (ref = remote_refs; ref; ref = ref->next) {
 		if (strchr(ref->name, '^'))
 			continue; /* a dereference item */
-		if (!prefixcmp(ref->name, refspec->src)) {
+		if (!prefixcmp(ref->name, refspec->src)
+		     && ref->name[remote_prefix_len] == '/') {
 			const char *match;
 			struct ref *cpy = copy_ref(ref);
 			match = ref->name + remote_prefix_len;
Previous: Junio C HamanoNext: Jeff King
Message 5 of 15 in “bash completion: Add completion for 'git help'”
  1. bash completion: Add completion for 'git help'Lee Marlow, Jul 23, 2008
  2. bash completion: Add completion for 'git help'Lee Marlow, Jul 24, 2008
  3. Shawn O. PearceJul 25, 2008
  4. Junio C HamanoJul 25, 2008
  5. fetch refspec foo/* matches foo*Jeff King, Jul 26, 2008
  6. Jeff KingJul 26, 2008
  7. Johannes SchindelinJul 26, 2008
  8. Jeff KingJul 28, 2008
  9. Junio C HamanoJul 28, 2008
  10. Jeff KingJul 28, 2008
  11. Junio C HamanoJul 27, 2008
  12. make sure parsed wildcard refspec ends with slashJunio C Hamano, Jul 27, 2008
  13. Daniel BarkalowJul 27, 2008
  14. Jeff KingJul 28, 2008
  15. bash completion: Add completion for 'git help'Lee Marlow, Jul 24, 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.