Skip to content

Commit 92f676f

Browse files
bertwesarggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e160da7 commit 92f676f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

builtin-remote.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
272272
die("Could not get fetch map for refspec %s",
273273
states->remote->fetch_refspec[i]);
274274

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;
276278
for (ref = fetch_map; ref; ref = ref->next) {
277279
unsigned char sha1[20];
278280
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)
768770
static void free_remote_ref_states(struct ref_states *states)
769771
{
770772
string_list_clear(&states->new, 0);
771-
string_list_clear(&states->stale, 0);
773+
string_list_clear(&states->stale, 1);
772774
string_list_clear(&states->tracked, 0);
773775
string_list_clear(&states->heads, 0);
774776
string_list_clear_func(&states->push, clear_push_info);

0 commit comments

Comments
 (0)