diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2012-09-09 08:19:40 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-09-12 11:46:31 -0700 |
commit | 8bee93dd24731a1d2ef7c82d484a893cf68b6572 (patch) | |
tree | b05bc4a6c12ba038300c7b5b58927df02346a9c0 /transport.c | |
parent | 63c694534bbe93a188ed74396a1a3ace0b24d6ad (diff) | |
download | git-8bee93dd24731a1d2ef7c82d484a893cf68b6572.tar.gz |
Change fetch_pack() and friends to take string_list arguments
Instead of juggling <nr_heads,heads> (sometimes called
<nr_match,match>), pass around the list of references to be sought in
a single string_list variable called "sought". Future commits will
make more use of string_list functionality.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r-- | transport.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/transport.c b/transport.c index 1811b500d9..a847bf31e2 100644 --- a/transport.c +++ b/transport.c @@ -518,8 +518,8 @@ 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 orig_sought = STRING_LIST_INIT_DUP; + struct string_list sought = STRING_LIST_INIT_NODUP; const struct ref *refs; char *dest = xstrdup(transport->url); struct fetch_pack_args args; @@ -537,8 +537,10 @@ static int fetch_refs_via_pack(struct transport *transport, args.no_progress = !transport->progress; args.depth = data->options.depth; - for (i = 0; i < nr_heads; i++) - origh[i] = heads[i] = xstrdup(to_fetch[i]->name); + for (i = 0; i < nr_heads; i++) { + string_list_append(&orig_sought, to_fetch[i]->name); + string_list_append(&sought, orig_sought.items[orig_sought.nr - 1].string); + } if (!data->got_remote_heads) { connect_setup(transport, 0, 0); @@ -548,7 +550,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 +560,8 @@ 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); + string_list_clear(&orig_sought, 0); free(dest); return (refs ? 0 : -1); } |