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

Function update_worktree

builtin/receive-pack.c:1472–1495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1470}
1471
1472static const char *update_worktree(unsigned char *sha1, const struct worktree *worktree)
1473{
1474 const char *retval;
1475 char *git_dir;
1476 struct strvec env = STRVEC_INIT;
1477 int invoked_hook;
1478
1479 if (!worktree || !worktree->path)
1480 BUG("worktree->path must be non-NULL");
1481
1482 if (worktree->is_bare)
1483 return "denyCurrentBranch = updateInstead needs a worktree";
1484 git_dir = get_worktree_git_dir(worktree);
1485
1486 strvec_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir));
1487
1488 retval = push_to_checkout(sha1, &invoked_hook, &env, worktree->path);
1489 if (!invoked_hook)
1490 retval = push_to_deploy(sha1, &env, worktree);
1491
1492 strvec_clear(&env);
1493 free(git_dir);
1494 return retval;
1495}
1496
1497static const char *update(struct command *cmd, struct shallow_info *si)
1498{

Callers 1

updateFunction · 0.85

Calls 6

get_worktree_git_dirFunction · 0.85
strvec_pushfFunction · 0.85
absolute_pathFunction · 0.85
push_to_checkoutFunction · 0.85
push_to_deployFunction · 0.85
strvec_clearFunction · 0.85

Tested by

no test coverage detected