@matheusbsbs / matheus-bagliano / commits / 92f676fce7
Fork 0

get_ref_states: strdup entries and free util in stale list

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>

Bert Wesarg committed Dec 1, 2009 at 00:57 UTC 92f676fce7fb1e67cb10c7c7d0b5e7521ff829b4
1 file changed +4 -2
builtin-remote.c
+4 -2
@@ -272,7 +272,9 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
272 die("Could not get fetch map for refspec %s",
273 states->remote->fetch_refspec[i]);
274
275 - states->new.strdup_strings = states->tracked.strdup_strings = 1;
275 + states->new.strdup_strings = 1;
276 + states->tracked.strdup_strings = 1;
277 + states->stale.strdup_strings = 1;
278 for (ref = fetch_map; ref; ref = ref->next) {
279 unsigned char sha1[20];
280 if (!ref->peer_ref || read_ref(ref->peer_ref->name, sha1))
@@ -768,7 +770,7 @@ static void clear_push_info(void *util, const char *string)
770 static void free_remote_ref_states(struct ref_states *states)
771 {
772 string_list_clear(&states->new, 0);
771 - string_list_clear(&states->stale, 0);
773 + string_list_clear(&states->stale, 1);
774 string_list_clear(&states->tracked, 0);
775 string_list_clear(&states->heads, 0);
776 string_list_clear_func(&states->push, clear_push_info);