MCPcopy Index your code
hub / github.com/git/git / write_pack_data

Function write_pack_data

bundle.c:328–372  ·  view source on GitHub ↗

Write the pack data to bundle_fd */

Source from the content-addressed store, hash-verified

326
327/* Write the pack data to bundle_fd */
328static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)
329{
330 struct child_process pack_objects = CHILD_PROCESS_INIT;
331 int i;
332
333 strvec_pushl(&pack_objects.args,
334 "pack-objects",
335 "--stdout", "--thin", "--delta-base-offset",
336 NULL);
337 strvec_pushv(&pack_objects.args, pack_options->v);
338 if (revs->filter.choice)
339 strvec_pushf(&pack_objects.args, "--filter=%s",
340 list_objects_filter_spec(&revs->filter));
341 pack_objects.in = -1;
342 pack_objects.out = bundle_fd;
343 pack_objects.git_cmd = 1;
344
345 /*
346 * start_command() will close our descriptor if it's >1. Duplicate it
347 * to avoid surprising the caller.
348 */
349 if (pack_objects.out > 1) {
350 pack_objects.out = dup(pack_objects.out);
351 if (pack_objects.out < 0) {
352 error_errno(_("unable to dup bundle descriptor"));
353 child_process_clear(&pack_objects);
354 return -1;
355 }
356 }
357
358 if (start_command(&pack_objects))
359 return error(_("Could not spawn pack-objects"));
360
361 for (i = 0; i < revs->pending.nr; i++) {
362 struct object *object = revs->pending.objects[i].item;
363 if (object->flags & UNINTERESTING)
364 write_or_die(pack_objects.in, "^", 1);
365 write_or_die(pack_objects.in, oid_to_hex(&object->oid), the_hash_algo->hexsz);
366 write_or_die(pack_objects.in, "\n", 1);
367 }
368 close(pack_objects.in);
369 if (finish_command(&pack_objects))
370 return error(_("pack-objects died"));
371 return 0;
372}
373
374/*
375 * Write out bundle refs based on the tips already

Callers 1

create_bundleFunction · 0.85

Calls 11

strvec_pushlFunction · 0.85
strvec_pushvFunction · 0.85
strvec_pushfFunction · 0.85
list_objects_filter_specFunction · 0.85
error_errnoFunction · 0.85
child_process_clearFunction · 0.85
start_commandFunction · 0.85
errorFunction · 0.85
write_or_dieFunction · 0.85
oid_to_hexFunction · 0.85
finish_commandFunction · 0.85

Tested by

no test coverage detected