summaryrefslogtreecommitdiff
path: root/builtin/worktree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-09-09 20:53:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-09 20:53:07 (GMT)
commit1aadb47aad7f4648a1de1e2de84cbcf235eeff59 (patch)
treebb4d8194f9464b6b658b3be066fe3152b8be964d /builtin/worktree.c
parenta31677dde39747700c0b626a9642315cd542cc73 (diff)
parent27ed6ccc12a331a1e6014f2fe101a2c551167e9e (diff)
downloadgit-1aadb47aad7f4648a1de1e2de84cbcf235eeff59.zip
git-1aadb47aad7f4648a1de1e2de84cbcf235eeff59.tar.gz
git-1aadb47aad7f4648a1de1e2de84cbcf235eeff59.tar.bz2
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 378f332..df21469 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;