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

Re: [PATCH 1/2] fetch/push: allow refs/*:refs/*

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 21, 2012, 17:37 UTC
Message-ID
<7vpq6kdu31.fsf@alter.siamese.dyndns.org>
In-Reply-To
<50332E2D.2070602@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 19 quoted lines
>> diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
>> index 6207ecd..a3e3fa3 100644
>> --- a/builtin/fetch-pack.c
>> +++ b/builtin/fetch-pack.c
>> @@ -546,7 +546,7 @@ static void filter_refs(struct ref **refs, int nr_match, char **match)
>>  	for (ref = *refs; ref; ref = next) {
>>  		next = ref->next;
>>  		if (!memcmp(ref->name, "refs/", 5) &&
>> -		    check_refname_format(ref->name + 5, 0))
>> +		    check_refname_format(ref->name, 0))
>>  			; /* trash */
>>  		else if (args.fetch_all &&
>>  			 (!args.depth || prefixcmp(ref->name, "refs/tags/") )) {
>
> I understand that you didn't introduce this code, but it seems like a
> suspicious combination of conditions:
>
>     if ((ref->name starts with "refs/")
>         and (ref->name has invalid format))

This protects us from getting contaminated by bogus ref under refs/ when running "fetch refs/heads/*:refs/remotes/origin/*" no?

The remote side can also throw phony "I have this object, too, but not at a particular ref---this entry is only to let you know I have it, so that we can negotiate minimal transfer better" entries that are labelled with strings that do not begin with "refs/" and do not pass check_refname_format() (and because they are not refs, they do not have to pass the test) at us, and we do not want to filter them out in this function. But we do not want anything that is malformed under "refs/".

Previous: Michael HaggertyNext: Michael Haggerty
Message 4 of 8 in “further fixes of check_ref_format() users”
  1. 0/2 further fixes of check_ref_format() usersJunio C Hamano, Aug 20, 2012
  2. 1/2 fetch/push: allow refs/*:refs/*Junio C Hamano, Aug 20, 2012
  3. Michael HaggertyAug 21, 2012
  4. Junio C HamanoAug 21, 2012
  5. Michael HaggertyAug 22, 2012
  6. Junio C HamanoAug 22, 2012
  7. Junio C HamanoAug 22, 2012
  8. 2/2 get_fetch_map(): tighten checks on dest refsJunio C Hamano, Aug 20, 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.