Re: [PATCH] Fixed crash in fetching remote tags when there is not tags.
From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:40
Alex Riesen [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 [off-list ref] so he can put it into the patch queue. -- Shawn.