Skip to content

Commit

Permalink
get_ref_states: strdup entries and free util in stale list
Browse files Browse the repository at this point in the history
The entries in states->stale list is filled in handle_one_branch() that is
a call-back funcation to for_each_ref() using the callback parameter given
to it.  We need to strdup() the refnames (both the string list key and the
value stored in util) for more permanent storage and free them when we are
done.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Bert Wesarg authored and Junio C Hamano committed Dec 1, 2009
1 parent e160da7 commit 92f676f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions builtin-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
die("Could not get fetch map for refspec %s",
states->remote->fetch_refspec[i]);

states->new.strdup_strings = states->tracked.strdup_strings = 1;
states->new.strdup_strings = 1;
states->tracked.strdup_strings = 1;
states->stale.strdup_strings = 1;
for (ref = fetch_map; ref; ref = ref->next) {
unsigned char sha1[20];
if (!ref->peer_ref || read_ref(ref->peer_ref->name, sha1))
Expand Down Expand Up @@ -768,7 +770,7 @@ static void clear_push_info(void *util, const char *string)
static void free_remote_ref_states(struct ref_states *states)
{
string_list_clear(&states->new, 0);
string_list_clear(&states->stale, 0);
string_list_clear(&states->stale, 1);
string_list_clear(&states->tracked, 0);
string_list_clear(&states->heads, 0);
string_list_clear_func(&states->push, clear_push_info);
Expand Down

0 comments on commit 92f676f

Please sign in to comment.