| 1265 | } |
| 1266 | |
| 1267 | static void parse_fetch(struct strbuf *buf) |
| 1268 | { |
| 1269 | struct ref **to_fetch = NULL; |
| 1270 | struct ref *list_head = NULL; |
| 1271 | struct ref **list = &list_head; |
| 1272 | int alloc_heads = 0, nr_heads = 0; |
| 1273 | |
| 1274 | do { |
| 1275 | const char *p; |
| 1276 | if (skip_prefix(buf->buf, "fetch ", &p)) { |
| 1277 | const char *name; |
| 1278 | struct ref *ref; |
| 1279 | struct object_id old_oid; |
| 1280 | const char *q; |
| 1281 | |
| 1282 | if (parse_oid_hex(p, &old_oid, &q)) |
| 1283 | die(_("protocol error: expected sha/ref, got '%s'"), p); |
| 1284 | if (*q == ' ') |
| 1285 | name = q + 1; |
| 1286 | else if (!*q) |
| 1287 | name = ""; |
| 1288 | else |
| 1289 | die(_("protocol error: expected sha/ref, got '%s'"), p); |
| 1290 | |
| 1291 | ref = alloc_ref(name); |
| 1292 | oidcpy(&ref->old_oid, &old_oid); |
| 1293 | |
| 1294 | *list = ref; |
| 1295 | list = &ref->next; |
| 1296 | |
| 1297 | ALLOC_GROW(to_fetch, nr_heads + 1, alloc_heads); |
| 1298 | to_fetch[nr_heads++] = ref; |
| 1299 | } |
| 1300 | else |
| 1301 | die(_("http transport does not support %s"), buf->buf); |
| 1302 | |
| 1303 | strbuf_reset(buf); |
| 1304 | if (strbuf_getline_lf(buf, stdin) == EOF) |
| 1305 | return; |
| 1306 | if (!*buf->buf) |
| 1307 | break; |
| 1308 | } while (1); |
| 1309 | |
| 1310 | if (fetch(nr_heads, to_fetch)) |
| 1311 | exit(128); /* error already reported */ |
| 1312 | free_refs(list_head); |
| 1313 | free(to_fetch); |
| 1314 | |
| 1315 | printf("\n"); |
| 1316 | fflush(stdout); |
| 1317 | strbuf_reset(buf); |
| 1318 | } |
| 1319 | |
| 1320 | static void parse_get(const char *arg) |
| 1321 | { |
no test coverage detected