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

Re: [PATCH] Fixed crash in fetching remote tags when there is not tags.

From
Shawn O. Pearce <spearce@spearce.org>
Date
Oct 12, 2007, 04:07 UTC
Message-ID
<20071012040745.GC27899@spearce.org>
In-Reply-To
<20071010212735.GB16635@steel.home>
Alex Riesen <raa.lkml@gmail.com> wrote:
Show 23 quoted lines
> Still, I'd suggest move the test into the caller, firstly because it
> is the only place that special. Also, I can't think of a proper reason
> to add a NULL ref to a reflist, and so the crashing tail_link_ref will
> help us find the callers which use tail_link_ref incorrectly
> (illogically too).
> 
> As the result of patter expansion can be NULL (empty pattern, as it
> seems), lets just check for it. I parked the patch below locally.
> 
> diff --git a/remote.c b/remote.c
> index 5e92378..58d63ed 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -884,7 +884,8 @@ int get_fetch_map(struct ref *remote_refs,
>  			    rm->peer_ref->name);
>  	}
>  
> -	tail_link_ref(ref_map, tail);
> +	if (ref_map)
> +		tail_link_ref(ref_map, tail);
>  
>  	return 0;
>  }

I disagree with Alex's argument above, because the result of the pattern expansion can be NULL due to a pattern that matched nothing from the remote. This can easily happen if the user originally configured "remote.$name.fetch = +refs/heads/subdir/*:..." and then the remote deletes all branches from refs/heads/subdir at some point in the future.

I think the above patch is the only thing to do here. Perhaps Alex can write up a formal patch and send it to back to the list and CC Lars Hjemli <hjemli@gmail.com> so he can put it into the patch queue.

-- 
Shawn.
Previous: Jeff KingNext: Alex Riesen
Message 8 of 10 in “Added a test for fetching remote tags when there is not tags.”
  1. Added a test for fetching remote tags when there is not tags.Väinö Järvelä, Oct 9, 2007
  2. Fixed crash in fetching remote tags when there is not tags.Väinö Järvelä, Oct 9, 2007
  3. Väinö JärveläOct 9, 2007
  4. Alex RiesenOct 9, 2007
  5. Jeff KingOct 10, 2007
  6. Alex RiesenOct 10, 2007
  7. Jeff KingOct 10, 2007
  8. Shawn O. PearceOct 12, 2007
  9. Fix a crash in ls-remote when refspec expands into nothingAlex Riesen, Oct 12, 2007
  10. Lars HjemliOct 14, 2007

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.