receive-pack: clean dead code from update_worktree()
update_worktree() can only be called with a non-NULL worktree parameter, because that’s the only case where we set do_update_worktree = 1. worktree->path is always initialized to non-NULL. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
8bc1f39f41
commit
38baae6cfe
@ -1449,29 +1449,22 @@ static const char *push_to_checkout(unsigned char *hash,
|
|||||||
|
|
||||||
static const char *update_worktree(unsigned char *sha1, const struct worktree *worktree)
|
static const char *update_worktree(unsigned char *sha1, const struct worktree *worktree)
|
||||||
{
|
{
|
||||||
const char *retval, *work_tree, *git_dir = NULL;
|
const char *retval, *git_dir;
|
||||||
struct strvec env = STRVEC_INIT;
|
struct strvec env = STRVEC_INIT;
|
||||||
|
|
||||||
if (worktree && worktree->path)
|
if (!worktree || !worktree->path)
|
||||||
work_tree = worktree->path;
|
BUG("worktree->path must be non-NULL");
|
||||||
else if (git_work_tree_cfg)
|
|
||||||
work_tree = git_work_tree_cfg;
|
|
||||||
else
|
|
||||||
work_tree = "..";
|
|
||||||
|
|
||||||
if (is_bare_repository())
|
if (is_bare_repository())
|
||||||
return "denyCurrentBranch = updateInstead needs a worktree";
|
return "denyCurrentBranch = updateInstead needs a worktree";
|
||||||
if (worktree)
|
git_dir = get_worktree_git_dir(worktree);
|
||||||
git_dir = get_worktree_git_dir(worktree);
|
|
||||||
if (!git_dir)
|
|
||||||
git_dir = get_git_dir();
|
|
||||||
|
|
||||||
strvec_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir));
|
strvec_pushf(&env, "GIT_DIR=%s", absolute_path(git_dir));
|
||||||
|
|
||||||
if (!hook_exists(push_to_checkout_hook))
|
if (!hook_exists(push_to_checkout_hook))
|
||||||
retval = push_to_deploy(sha1, &env, work_tree);
|
retval = push_to_deploy(sha1, &env, worktree->path);
|
||||||
else
|
else
|
||||||
retval = push_to_checkout(sha1, &env, work_tree);
|
retval = push_to_checkout(sha1, &env, worktree->path);
|
||||||
|
|
||||||
strvec_clear(&env);
|
strvec_clear(&env);
|
||||||
return retval;
|
return retval;
|
||||||
@ -1592,9 +1585,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (do_update_worktree) {
|
if (do_update_worktree) {
|
||||||
ret = update_worktree(new_oid->hash,
|
ret = update_worktree(new_oid->hash, worktree);
|
||||||
find_shared_symref(worktrees, "HEAD",
|
|
||||||
name));
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user