diff options
Diffstat (limited to 'transport.c')
-rw-r--r-- | transport.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/transport.c b/transport.c index 1811b500d9..b9306ef645 100644 --- a/transport.c +++ b/transport.c @@ -518,8 +518,7 @@ static int fetch_refs_via_pack(struct transport *transport, int nr_heads, struct ref **to_fetch) { struct git_transport_data *data = transport->data; - char **heads = xmalloc(nr_heads * sizeof(*heads)); - char **origh = xmalloc(nr_heads * sizeof(*origh)); + struct string_list sought = STRING_LIST_INIT_DUP; const struct ref *refs; char *dest = xstrdup(transport->url); struct fetch_pack_args args; @@ -538,7 +537,7 @@ static int fetch_refs_via_pack(struct transport *transport, args.depth = data->options.depth; for (i = 0; i < nr_heads; i++) - origh[i] = heads[i] = xstrdup(to_fetch[i]->name); + string_list_append(&sought, to_fetch[i]->name); if (!data->got_remote_heads) { connect_setup(transport, 0, 0); @@ -548,7 +547,7 @@ static int fetch_refs_via_pack(struct transport *transport, refs = fetch_pack(&args, data->fd, data->conn, refs_tmp ? refs_tmp : transport->remote_refs, - dest, nr_heads, heads, &transport->pack_lockfile); + dest, &sought, &transport->pack_lockfile); close(data->fd[0]); close(data->fd[1]); if (finish_connect(data->conn)) @@ -558,10 +557,7 @@ static int fetch_refs_via_pack(struct transport *transport, free_refs(refs_tmp); - for (i = 0; i < nr_heads; i++) - free(origh[i]); - free(origh); - free(heads); + string_list_clear(&sought, 0); free(dest); return (refs ? 0 : -1); } @@ -745,7 +741,7 @@ void transport_print_push_status(const char *dest, struct ref *refs, n += print_one_push_status(ref, dest, n, porcelain); if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD && *nonfastforward != NON_FF_HEAD) { - if (!strcmp(head, ref->name)) + if (head != NULL && !strcmp(head, ref->name)) *nonfastforward = NON_FF_HEAD; else *nonfastforward = NON_FF_OTHER; |