remote-curl: pass buffer straight to get_remote_heads
Until recently, get_remote_heads only knew how to read refs from a file descriptor. To hack around this, we spawned a thread (or forked a process) to write the buffer back to us. Now that we can just pass it our buffer directly, we don't have to use this hack anymore. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 20, 2013 at 15:07 UTC
5dbf43602de31cac518607b4d9a04a40d7b154c8
1 file changed
+2
-24
remote-curl.c
+2
-24
@@ -170,33 +170,11 @@ static struct discovery* discover_refs(const char *service)
170
return last;
171
}
172
173
-static int write_discovery(int in, int out, void *data)
174
-{
175
- struct discovery *heads = data;
176
- int err = 0;
177
- if (write_in_full(out, heads->buf, heads->len) != heads->len)
178
- err = 1;
179
- close(out);
180
- return err;
181
-}
182
-
173
static struct ref *parse_git_refs(struct discovery *heads, int for_push)
174
{
175
struct ref *list = NULL;
186
- struct async async;
187
-
188
- memset(&async, 0, sizeof(async));
189
- async.proc = write_discovery;
190
- async.data = heads;
191
- async.out = -1;
192
-
193
- if (start_async(&async))
194
- die("cannot start thread to parse advertised refs");
195
- get_remote_heads(async.out, NULL, 0, &list,
196
- for_push ? REF_NORMAL : 0, NULL);
197
- close(async.out);
198
- if (finish_async(&async))
199
- die("ref parsing thread failed");
176
+ get_remote_heads(-1, heads->buf, heads->len, &list,
177
+ for_push ? REF_NORMAL : 0, NULL);
178
return list;
179
}
180