]> git.ipfire.org Git - thirdparty/git.git/commit - remote.c
remote: make copy_ref() perform a deep copy
authorJay Soffian <jaysoffian@gmail.com>
Fri, 27 Feb 2009 19:10:04 +0000 (14:10 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Feb 2009 23:08:08 +0000 (15:08 -0800)
commit7b3db095d53d19e08b27114d8706ff3be6693af7
tree60231bbfbede85ab1672129b7ca3f375c982a421
parent6cb4e6cc0f5b2de1998492b0178eeb0f99d4a800
remote: make copy_ref() perform a deep copy

To ensure that copied refs can always be freed w/o causing a
double-free, make copy_ref() perform a deep copy.

Also have copy_ref() return NULL if asked to copy NULL to simplify
things for the caller.

Background: currently copy_ref() performs a shallow copy. This is fine
for current callers who never free the result and/or only copy refs
which contain NULL pointers. But copy_ref() is about to gain a new
caller (guess_remote_head()) which copies refs where peer_ref is not
NULL and the caller of guess_remote_head() will want to free the result.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c