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

Function push_to_deploy

builtin/receive-pack.c:1388–1450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1386}
1387
1388static const char *push_to_deploy(unsigned char *sha1,
1389 struct strvec *env,
1390 const struct worktree *worktree)
1391{
1392 struct child_process child = CHILD_PROCESS_INIT;
1393
1394 strvec_pushl(&child.args, "update-index", "-q", "--ignore-submodules",
1395 "--refresh", NULL);
1396 strvec_pushv(&child.env, env->v);
1397 child.dir = worktree->path;
1398 child.no_stdin = 1;
1399 child.stdout_to_stderr = 1;
1400 child.git_cmd = 1;
1401 if (run_command(&child))
1402 return "Up-to-date check failed";
1403
1404 /* run_command() does not clean up completely; reinitialize */
1405 child_process_init(&child);
1406 strvec_pushl(&child.args, "diff-files", "--quiet",
1407 "--ignore-submodules", "--", NULL);
1408 strvec_pushv(&child.env, env->v);
1409 child.dir = worktree->path;
1410 child.no_stdin = 1;
1411 child.stdout_to_stderr = 1;
1412 child.git_cmd = 1;
1413 if (run_command(&child))
1414 return "Working directory has unstaged changes";
1415
1416 child_process_init(&child);
1417 strvec_pushl(&child.args, "diff-index", "--quiet", "--cached",
1418 "--ignore-submodules",
1419 /*
1420 * diff-index with either HEAD or an empty tree
1421 *
1422 * NEEDSWORK: is_null_oid() cannot know whether it's an
1423 * unborn HEAD or a corrupt ref. It works for now because
1424 * it's only needed to know if we are comparing HEAD or an
1425 * empty tree.
1426 */
1427 !is_null_oid(&worktree->head_oid) ? "HEAD" :
1428 empty_tree_oid_hex(the_repository->hash_algo), "--", NULL);
1429 strvec_pushv(&child.env, env->v);
1430 child.no_stdin = 1;
1431 child.no_stdout = 1;
1432 child.stdout_to_stderr = 0;
1433 child.git_cmd = 1;
1434 if (run_command(&child))
1435 return "Working directory has staged changes";
1436
1437 child_process_init(&child);
1438 strvec_pushl(&child.args, "read-tree", "-u", "-m", hash_to_hex(sha1),
1439 NULL);
1440 strvec_pushv(&child.env, env->v);
1441 child.dir = worktree->path;
1442 child.no_stdin = 1;
1443 child.no_stdout = 1;
1444 child.stdout_to_stderr = 0;
1445 child.git_cmd = 1;

Callers 1

update_worktreeFunction · 0.85

Calls 7

strvec_pushlFunction · 0.85
strvec_pushvFunction · 0.85
run_commandFunction · 0.85
child_process_initFunction · 0.85
is_null_oidFunction · 0.85
empty_tree_oid_hexFunction · 0.85
hash_to_hexFunction · 0.85

Tested by

no test coverage detected