* Make a pack stream and spit it out into file descriptor fd */
| 58 | * Make a pack stream and spit it out into file descriptor fd |
| 59 | */ |
| 60 | static int pack_objects(struct repository *r, |
| 61 | int fd, struct ref *refs, struct oid_array *advertised, |
| 62 | struct oid_array *negotiated, |
| 63 | struct send_pack_args *args) |
| 64 | { |
| 65 | /* |
| 66 | * The child becomes pack-objects --revs; we feed |
| 67 | * the revision parameters to it via its stdin and |
| 68 | * let its stdout go back to the other end. |
| 69 | */ |
| 70 | struct child_process po = CHILD_PROCESS_INIT; |
| 71 | FILE *po_in; |
| 72 | int rc; |
| 73 | |
| 74 | trace2_region_enter("send_pack", "pack_objects", r); |
| 75 | strvec_push(&po.args, "pack-objects"); |
| 76 | strvec_push(&po.args, "--all-progress-implied"); |
| 77 | strvec_push(&po.args, "--revs"); |
| 78 | strvec_push(&po.args, "--stdout"); |
| 79 | if (args->use_thin_pack) |
| 80 | strvec_push(&po.args, "--thin"); |
| 81 | if (args->use_ofs_delta) |
| 82 | strvec_push(&po.args, "--delta-base-offset"); |
| 83 | if (args->quiet || !args->progress) |
| 84 | strvec_push(&po.args, "-q"); |
| 85 | if (args->progress) |
| 86 | strvec_push(&po.args, "--progress"); |
| 87 | if (is_repository_shallow(r)) |
| 88 | strvec_push(&po.args, "--shallow"); |
| 89 | if (args->disable_bitmaps) |
| 90 | strvec_push(&po.args, "--no-use-bitmap-index"); |
| 91 | po.in = -1; |
| 92 | po.out = args->stateless_rpc ? -1 : fd; |
| 93 | po.git_cmd = 1; |
| 94 | po.clean_on_exit = 1; |
| 95 | if (start_command(&po)) |
| 96 | die_errno("git pack-objects failed"); |
| 97 | |
| 98 | /* |
| 99 | * We feed the pack-objects we just spawned with revision |
| 100 | * parameters by writing to the pipe. |
| 101 | */ |
| 102 | po_in = xfdopen(po.in, "w"); |
| 103 | for (size_t i = 0; i < advertised->nr; i++) |
| 104 | feed_object(r, &advertised->oid[i], po_in, 1); |
| 105 | for (size_t i = 0; i < negotiated->nr; i++) |
| 106 | feed_object(r, &negotiated->oid[i], po_in, 1); |
| 107 | |
| 108 | while (refs) { |
| 109 | if (!is_null_oid(&refs->old_oid)) |
| 110 | feed_object(r, &refs->old_oid, po_in, 1); |
| 111 | if (!is_null_oid(&refs->new_oid)) |
| 112 | feed_object(r, &refs->new_oid, po_in, 0); |
| 113 | refs = refs->next; |
| 114 | } |
| 115 | |
| 116 | fflush(po_in); |
| 117 | if (ferror(po_in)) |
no test coverage detected