MCPcopy Create free account
hub / github.com/git/git / unpack

Function unpack

builtin/receive-pack.c:2329–2432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2327}
2328
2329static const char *unpack(int err_fd, struct shallow_info *si)
2330{
2331 struct pack_header hdr;
2332 const char *hdr_err;
2333 int status;
2334 struct child_process child = CHILD_PROCESS_INIT;
2335 int fsck_objects = (receive_fsck_objects >= 0
2336 ? receive_fsck_objects
2337 : transfer_fsck_objects >= 0
2338 ? transfer_fsck_objects
2339 : 0);
2340
2341 hdr_err = parse_pack_header(&hdr);
2342 if (hdr_err) {
2343 if (err_fd > 0)
2344 close(err_fd);
2345 return hdr_err;
2346 }
2347
2348 if (si->nr_ours || si->nr_theirs) {
2349 alt_shallow_file = setup_temporary_shallow(si->shallow);
2350 strvec_push(&child.args, "--shallow-file");
2351 strvec_push(&child.args, alt_shallow_file);
2352 }
2353
2354 tmp_objdir = tmp_objdir_create(the_repository, "incoming");
2355 if (!tmp_objdir) {
2356 if (err_fd > 0)
2357 close(err_fd);
2358 return "unable to create temporary object directory";
2359 }
2360 strvec_pushv(&child.env, tmp_objdir_env(tmp_objdir));
2361
2362 /*
2363 * Normally we just pass the tmp_objdir environment to the child
2364 * processes that do the heavy lifting, but we may need to see these
2365 * objects ourselves to set up shallow information.
2366 */
2367 tmp_objdir_add_as_alternate(tmp_objdir);
2368
2369 if (ntohl(hdr.hdr_entries) < unpack_limit) {
2370 strvec_push(&child.args, "unpack-objects");
2371 push_header_arg(&child.args, &hdr);
2372 if (quiet)
2373 strvec_push(&child.args, "-q");
2374 if (fsck_objects)
2375 strvec_pushf(&child.args, "--strict%s",
2376 fsck_msg_types.buf);
2377 if (max_input_size)
2378 strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX,
2379 (uintmax_t)max_input_size);
2380 child.no_stdout = 1;
2381 child.err = err_fd;
2382 child.git_cmd = 1;
2383 status = run_command(&child);
2384 if (status)
2385 return "unpack-objects abnormal exit";
2386 } else {

Callers 1

unpack_with_sidebandFunction · 0.70

Calls 15

setup_temporary_shallowFunction · 0.85
strvec_pushFunction · 0.85
tmp_objdir_createFunction · 0.85
strvec_pushvFunction · 0.85
tmp_objdir_envFunction · 0.85
push_header_argFunction · 0.85
strvec_pushfFunction · 0.85
run_commandFunction · 0.85
strvec_pushlFunction · 0.85
xgethostnameFunction · 0.85
xsnprintfFunction · 0.85

Tested by

no test coverage detected