Re: [PATCH 08/21] remote: let guess_remote_head() optionally return all matches
- From
Jeff King <peff@peff.net>
- Date
- Feb 26, 2009, 14:37 UTC
- Message-ID
- <20090226143729.GA9693@coredump.intra.peff.net>
- In-Reply-To
- <ad3c408c208c8a829b1e4a0c0818e808b19e1dfc.1235546708.git.jaysoffian@gmail.com>
On Wed, Feb 25, 2009 at 03:32:15AM -0500, Jay Soffian wrote:
Show 6 quoted lines
> +struct ref *copy_ref_with_peer(const struct ref *src)
> +{
> + struct ref *dst = copy_ref(src);
> + dst->peer_ref = copy_ref(src->peer_ref);
> + return dst;
> +}Hmm. This should probably be:
dst->peer_ref = src->peer_ref ? copy_ref(src->peer_ref) : NULL;
(or copy_ref should return NULL when given NULL). I also wonder if the copied ref's peer_ref should be explicitly NULL'd.
I don't think it matters for the current code, since we always feed it "matched refs" which have a peer, but I think it is good to be a little more defensive in such a generically-named function.
And yes, this bug was in my original patch. :)
-Peff