summaryrefslogtreecommitdiff
path: root/builtin/worktree.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-09-09 13:53:07 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-09-09 13:53:07 -0700
commit1aadb47aad7f4648a1de1e2de84cbcf235eeff59 (patch)
treebb4d8194f9464b6b658b3be066fe3152b8be964d /builtin/worktree.c
parentMerge branch 'tb/repack-clearing-midx' (diff)
parentworktree: fix leak in check_clean_worktree() (diff)
downloadtgif-1aadb47aad7f4648a1de1e2de84cbcf235eeff59.tar.xz
Merge branch 'jk/worktree-check-clean-leakfix'
Leakfix. * jk/worktree-check-clean-leakfix: worktree: fix leak in check_clean_worktree()
Diffstat (limited to 'builtin/worktree.c')
-rw-r--r--builtin/worktree.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 378f332b5d..df214697d2 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -924,7 +924,6 @@ static int move_worktree(int ac, const char **av, const char *prefix)
static void check_clean_worktree(struct worktree *wt,
const char *original_path)
{
- struct strvec child_env = STRVEC_INIT;
struct child_process cp;
char buf[1];
int ret;
@@ -935,15 +934,14 @@ static void check_clean_worktree(struct worktree *wt,
*/
validate_no_submodules(wt);
- strvec_pushf(&child_env, "%s=%s/.git",
+ child_process_init(&cp);
+ strvec_pushf(&cp.env_array, "%s=%s/.git",
GIT_DIR_ENVIRONMENT, wt->path);
- strvec_pushf(&child_env, "%s=%s",
+ strvec_pushf(&cp.env_array, "%s=%s",
GIT_WORK_TREE_ENVIRONMENT, wt->path);
- memset(&cp, 0, sizeof(cp));
strvec_pushl(&cp.args, "status",
"--porcelain", "--ignore-submodules=none",
NULL);
- cp.env = child_env.v;
cp.git_cmd = 1;
cp.dir = wt->path;
cp.out = -1;