From patchwork Thu Oct 27 16:35:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13022367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 792BAECAAA1 for ; Thu, 27 Oct 2022 16:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235052AbiJ0QfY (ORCPT ); Thu, 27 Oct 2022 12:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235597AbiJ0QfU (ORCPT ); Thu, 27 Oct 2022 12:35:20 -0400 Received: from mout.web.de (mout.web.de [212.227.15.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D737220356 for ; Thu, 27 Oct 2022 09:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1666888503; bh=hUPIERufh2YPKYUYEFtjKEriqayeFlciFf3o4OX2rFY=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=bmfjlte0CqG7bS41BGFIrw966KnPtoGqdXsNFwqhwmiNSa2OI6aDF3WFFKaL8UQXA o4aLiq86HtfrDqkGiAVx/dcAbcKDbBjWnj6oXv0CDsSLp0a1LwOwxxAhGs3od5G7cU /bwL2H4YCQOxYpbaEE/va/jyvSvVsOijQ1x9G8mixlRKpWkJ+aVtuJ4OWnwPZQleFD ByCxeMREXvRjcWuXwWxvfRRJ5wrpIZdxi/s5PY45pawRBzmMQlra+u6HAWaEnAA9Qa SgBqtS2bhkKrBVkqUcn25awrZuEsoGQjf/xCmX86tDAso3aAoSmqcUXdy3ZEkgFFXE biqxaulnN7Fkw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.23.191]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MnG2C-1pX1V50w32-00jIOk; Thu, 27 Oct 2022 18:35:03 +0200 Message-ID: <0cae80c0-2576-8be7-48f7-06a0a135961f@web.de> Date: Thu, 27 Oct 2022 18:35:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH 1/8] merge: remove always-the-same "verbose" arguments Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git List Cc: Junio C Hamano , Taylor Blau , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= References: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> In-Reply-To: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> X-Provags-ID: V03:K1:czNccu2pYPC9z9jMaMsxf9cE8wqZFFKj30Y9zigKufZyqM3vRnb FNk8il+LbHcHnGrBkHr4Br3bZfIih8mNumSxe+VdIw9Co0+P7//p0XDYcRkBHYXUH1n6mYI h5+kNdUS49gSyx6BGjd98ZhAYH/Xnf5g0qBzasreRKBsS7rGO1cCfH7ofJq9u0J4oujzo7D tp9BzryZTbUThhcUhrGVQ== UI-OutboundReport: notjunk:1;M01:P0:6sgb3lW/tO4=;KmUKXCtaZDFyJ6ohgXpp/Gs+XEG 9sdCVfQjqndBrv8fXrAFIMpvU6URbAWmPI0wRa68j30PETOsqMnyrwl/XHgEgIDK8dz6B+bsf QJ4X3Qp+dBHf6wCsKCBfcNgPhP1e01dSRTV7oeQKtsgDDLFHKp8xyAtfwM86QGJLJcKgm+eaz dmVE+XxZOUF78K9FkYG+j1p3x5zmi6ZDccp2gFkylYCgFU4EzmHWttruAPNfkr0c2TqGRiNvv h2rsiVcRSZwPA11O+gKT7bSqAkAkGuSpI5tFdn0LPgpAg8jB1wUEzCGqUAKRz7h1Cju74Z8rx C47nW8Yodb5E1hiFTRZGSbneAHABoZX0alOe+jsjZulgSPgvpf7qpp5l92pjG2GQgdFk9aMC4 UBpCSjWyq90L0jBeVa4RuSBL8PldXfUYSVaF6UgBXQ5pq08mo1zQ1dIeADNKEUEgBQ9JO+gq+ eR5nzaDUd7dF4NKKWEZc2DPdhzakgYS/PTto8LwVzTFExPie01BaNrQqQM0ieNXTKGHE+yzfk DZheALM/gDzjr5V6vfhsmsmEmADjpibNzw2uK0sEBHw707P7mo+71PXyiwqta3pOZSjCYilQn 7AWpZHaC7MmRK4fNkb9tZjkC/LQ1UYZ3EWtj3Xt4cTjn5G1GMhz6YMo4Cvtvp8Jz+fVQkqIKk fH79K5NHIgNidHyOsfu23YfkJn8qBd4f3pApZAkvPG6uY+xgLiR2XCrP2zS4GWCyGfCCJQRHs EsKfTFkRPF+edOvvpnSJSbRx1FD4gCxZItMUTsJuQ/mrx6MbkvIMPHQGLGOdgXBLSMPdNukHd 7w5qQJu4Q2mWMz0cXhSATwtC2w526vUWH//w5hh6f//AgyTxZp302T5F5UOmzaRaE0z5uW1ic uQhlnQz8zfy0oGIe4SzV9OrXxJxvGhi+43J2dPX7rlm8WX20yuzRr5GhI82YHLfZAznXmRQH0 HVW3Fg== Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ævar Arnfjörð Bjarmason Simplify the code that builds the arguments for the "read-tree" invocation in reset_hard() and read_empty() to remove the "verbose" parameter. Before 172b6428d06 (do not overwrite untracked during merge from unborn branch, 2010-11-14) there was a "reset_hard()" function that would be called in two places, one of those passed a "verbose=1", the other a "verbose=0". After 172b6428d06 when read_empty() was split off from reset_hard() both of these functions only had one caller. The "verbose" in read_empty() would always be false, and the one in reset_hard() would always be true. There was never a good reason for the code to act this way, it happened because the read_empty() function was a copy/pasted and adjusted version of reset_hard(). Since we're no longer conditionally adding the "-v" parameter here (and we'd only add it for "reset_hard()" we'll be able to move to a simpler and safer run-command API in the subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: René Scharfe --- builtin/merge.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.38.1 diff --git a/builtin/merge.c b/builtin/merge.c index 5900b81729..3bb49d805b 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -345,14 +345,12 @@ static int save_state(struct object_id *stash) return rc; } -static void read_empty(const struct object_id *oid, int verbose) +static void read_empty(const struct object_id *oid) { int i = 0; const char *args[7]; args[i++] = "read-tree"; - if (verbose) - args[i++] = "-v"; args[i++] = "-m"; args[i++] = "-u"; args[i++] = empty_tree_oid_hex(); @@ -363,14 +361,13 @@ static void read_empty(const struct object_id *oid, int verbose) die(_("read-tree failed")); } -static void reset_hard(const struct object_id *oid, int verbose) +static void reset_hard(const struct object_id *oid) { int i = 0; const char *args[6]; args[i++] = "read-tree"; - if (verbose) - args[i++] = "-v"; + args[i++] = "-v"; args[i++] = "--reset"; args[i++] = "-u"; args[i++] = oid_to_hex(oid); @@ -385,7 +382,7 @@ static void restore_state(const struct object_id *head, { struct strvec args = STRVEC_INIT; - reset_hard(head, 1); + reset_hard(head); if (is_null_oid(stash)) goto refresh_cache; @@ -1470,7 +1467,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) check_trust_level); remote_head_oid = &remoteheads->item->object.oid; - read_empty(remote_head_oid, 0); + read_empty(remote_head_oid); update_ref("initial pull", "HEAD", remote_head_oid, NULL, 0, UPDATE_REFS_DIE_ON_ERR); goto done; From patchwork Thu Oct 27 16:35:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13022368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33D8EFA3740 for ; Thu, 27 Oct 2022 16:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236625AbiJ0QgM (ORCPT ); Thu, 27 Oct 2022 12:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236612AbiJ0QgG (ORCPT ); Thu, 27 Oct 2022 12:36:06 -0400 Received: from mout.web.de (mout.web.de [212.227.15.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BFB05BC97 for ; Thu, 27 Oct 2022 09:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1666888553; bh=2GRrFBWZ4Y2h4z5MGFMt+f4CSdPpDbxq5Rm/vTOXe3o=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=lplf4KUBfHxvpiVoDV7dPvm0e4DOo6VY2/lzvq5LJyw5yYBdtFkdqrHMRo2vevPwt R3zOmnpsj934TE6mPpK/HP4USbLRM90YNClUXNtUC8y+CuBfSDr6WlK5Pj7viLSHFB n7Z1vXBQzhjQ+iSGPj3XU5DQ9DFhO8aq2qp3AjNdue+v5/dDOmuwiRPO6e4L2OJuc6 qJ4BypUqL6ohX6daPSzYIlck1AlVqXC8WE+lRaADEgju1vGor9y3evRzXe5p0pSFGX mn7ePvj+7c5m/rUWyPbRJU8AFM+oVfVGR1w4oer8qPPp64lNUrD2ed59u7UY9dbU4q 2xBwb7bhFYohA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.23.191]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MJWsm-1oUN733HXU-00JtMT; Thu, 27 Oct 2022 18:35:53 +0200 Message-ID: <033ebd37-40c7-01bc-e9bb-29d738532125@web.de> Date: Thu, 27 Oct 2022 18:35:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH 2/8] bisect--helper: factor out do_bisect_run() Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git List Cc: Junio C Hamano , Taylor Blau , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= References: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> In-Reply-To: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> X-Provags-ID: V03:K1:aK0Nf2ANXr8FKrBxtAbMIOOklsn078xBGb9DWG9XjrRnp7h1oWZ D3uIvrB/Uu4v7tD3L0Xrs1a4cUZCSw2HRTyjuWtWbKRIbSNoC4AcfYXUKG13D+21nCrAGd/ /6aS1+lXfeZi32sqqxCr0fRKPKkNFy1PUO+UzVegrK21D9UcEOeJ2zpC59ZVLzHpmgE2Ua5 F4P/SxKnR+9zRyIngMPwg== UI-OutboundReport: notjunk:1;M01:P0:hhb4nIaghRM=;5bS4Bv9fBYi55eM3+Tupg7i59Nh FB8G3t/kyZXCEApyG5P/k1QIJrlJJiw7TYzmtRlbsNgpz84YbJhYrOrdqUCwmXp4shiknWJ7M /kDkZwNghopkxnCK9GJrnNFjv2lH+T1DcmsgQh6ab0RfhdL39Zif78B37jaSG1XYkpxEF+5Fv 7T8FDwHMj0U32te5KliTcJFspFIFU5j1Dp9I446en/uqKtBkd278DZ1DrmDNW4cs42SZ70wPg zFWQNW+ZqFPKvvNoQHp3JHqwrqj0++5ZvHPSCmrvSNbPW5jpEC5sJpxybV7QFeTqffHHshcwR 83pBWlvZMny4450lx4qrKqkRtfDVDSR/JqeYmZ/DH3gNkBnQDHQwN2XsUMLZutq0aX6sb+4gv ASkJ2ggAv0gHll9cDy6xV4nl7cjMxlcCknkmKmO7aOBRGNFW+J4xD2WAWC+ic+WHSONfur9vM NlEAPWv1pecWM6c49H4hPjIb4+DwctbnMuddMftW/6e6liacrrlyGPv8FWloPKRe8J71OWdcQ 9jkD9KeaCHwasA2iUzqOPxIP9A0ijDIDoRTHz2z9ZzOiB40dUbpaMRqEbeRRXZ067HmOq4eD0 eSASk4ofH+AG7emWRQiehvAm0eDEZsRzoqsEXQEeLI89jNi1amPlnmUo86tqqeVDsRVTwO4SD x2d+aS7ZEkRElfAWKXytbcuwZH+Kc1CO5OyXgwCQCznr/4HrZ3Ymb65IF5PP7GL807fMyI/FO NPSuAl2E2lV6VNedb2ap5fJLK38ZQRKsNhJhPK+yNY0pQJK44z3fJOeDDhPY1uarExL2NEv+v QFdbyUK9oUJpIkCWht3QPKe+b4hhp1eKcZsM7kaetEC0CFkuY3wdkKwntheRHxT+ebruGsnlb gI8g5Jz0O8sa+CwLcrgxai4qLpYh5+XY+ye0X5GN7fWtL+1Kivx2f7pGVebifH1JgC/mMV+4p Mz6S2TTQoKS5o8cuas7aDgEah+w= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Deduplicate the code for reporting and starting the bisect run command by moving it to a short helper function. Use a string array instead of a strvec to prepare the arguments, for simplicity. Signed-off-by: René Scharfe --- builtin/bisect--helper.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) -- 2.38.1 diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 28ef7ec2a4..70d1e9d1ad 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1142,8 +1142,14 @@ static int get_first_good(const char *refname UNUSED, return 1; } -static int verify_good(const struct bisect_terms *terms, - const char **quoted_argv) +static int do_bisect_run(const char *command) +{ + const char *argv[] = { command, NULL }; + printf(_("running %s\n"), command); + return run_command_v_opt(argv, RUN_USING_SHELL); +} + +static int verify_good(const struct bisect_terms *terms, const char *command) { int rc; enum bisect_error res; @@ -1163,8 +1169,7 @@ static int verify_good(const struct bisect_terms *terms, if (res != BISECT_OK) return -1; - printf(_("running %s\n"), quoted_argv[0]); - rc = run_command_v_opt(quoted_argv, RUN_USING_SHELL); + rc = do_bisect_run(command); res = bisect_checkout(¤t_rev, no_checkout); if (res != BISECT_OK) @@ -1177,7 +1182,6 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) { int res = BISECT_OK; struct strbuf command = STRBUF_INIT; - struct strvec run_args = STRVEC_INIT; const char *new_state; int temporary_stdout_fd, saved_stdout; int is_first_run = 1; @@ -1192,11 +1196,8 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) return BISECT_FAILED; } - strvec_push(&run_args, command.buf); - while (1) { - printf(_("running %s\n"), command.buf); - res = run_command_v_opt(run_args.v, RUN_USING_SHELL); + res = do_bisect_run(command.buf); /* * Exit code 126 and 127 can either come from the shell @@ -1206,7 +1207,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) * missing or non-executable script. */ if (is_first_run && (res == 126 || res == 127)) { - int rc = verify_good(terms, run_args.v); + int rc = verify_good(terms, command.buf); is_first_run = 0; if (rc < 0) { error(_("unable to verify '%s' on good" @@ -1273,7 +1274,6 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) } strbuf_release(&command); - strvec_clear(&run_args); return res; } From patchwork Thu Oct 27 16:36:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13022370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0EDAECAAA1 for ; Thu, 27 Oct 2022 16:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236452AbiJ0Qg6 (ORCPT ); Thu, 27 Oct 2022 12:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235972AbiJ0Qg5 (ORCPT ); Thu, 27 Oct 2022 12:36:57 -0400 Received: from mout.web.de (mout.web.de [212.227.15.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 979A41867BD for ; Thu, 27 Oct 2022 09:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1666888606; bh=B4xJqkKObNOkFhbRWHLJUXMZH56oAE9dklMoBG56oW4=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=o2wlLKvUtGtPqnsWVQn/hQwNOhMGsZmHX0SXj0na54PIeRvjl5vYnEGF24N3wkcab xH/K0W6bgDwFjQu/4AVM2Ed4E+vxo5vZUylxBEyp3PBeyM/WE7LrEuHR2d8NmLvTVE wC59hgNHEiiFAlVzYxFluicpnSJBIFawywuCowBZT5Las/VImXe5gss0GdakZc4aU5 X1xQjQpfwMF7FKm+zFC3mgihzgGkJQiMcpv42Ze7Dugjs7sgfOyeu8XyUjARhTSjxt MuxdXSDTW/23WlC8e2gQvc0ThBZ+4wK+ZIsnz5FESP1VOBrZ7xzleX/P2QcrVg4uDE 70UOxjt0eBEig== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.23.191]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MKdLM-1oVTcY0eJI-00Kz6z; Thu, 27 Oct 2022 18:36:46 +0200 Message-ID: <672e4176-81b4-bb9c-5a14-e558d24b0c0d@web.de> Date: Thu, 27 Oct 2022 18:36:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH 3/8] use child_process members "args" and "env" directly Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git List Cc: Junio C Hamano , Taylor Blau , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= References: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> In-Reply-To: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> X-Provags-ID: V03:K1:/i1Y1VGkliXBewUAqg/6AHqgPaTiN0r0fgXfbbOP9n0dmnHtYH2 htZS2/CfIOi8DXqMsQI2vue/lPC5ZlEPlrtkZn85o0YYOZJsL2kB6XN0o1FP0vh7DBu91P9 Ye+pt2oX64P8WEUtstrfTkchuoX0mqMPokxQJvCzUB1epwjmxetDHfs3MJGYJoBHrF1sose ZlZ15zHv2UmIiTQ6ydmdQ== UI-OutboundReport: notjunk:1;M01:P0:vfFzVVzSGbY=;lT/uo7LRhfXhSdk9L4fvdQtvvI6 UprmvOHT9IfwzHwF6aM7MjrjFQZ4lrPuq3hLKDKKcS9kolj9bQR4dU6DOVCoSYSFfOsY0Pxke xZD6n231tLkCWfW9rrpAK0t3aUCGuLOVKCAN491JSVMj7ns6IMFw3DbIRzD8P6iB9GbdWQz5/ AM+wn/1XV6MqJ18ZQ3QVGysaS1D1Ensvo45Yx8qQJ2ll935HvroTm+gET03pPME2a0xvnbXM5 D5J29SzD7ph12QKXgsQBFRJgjrMY1GdL5Cg1rjrEmSV58iRVgzlmK/N52yD+yG/z7ls8rqJK7 eMUibrm69+NkTMPAJrgfZjmeTwjLfVJ36adV1tfLQNNNEeXqsVsc7dDqkRrs7kW+AgTEcM5fz Kd8MtBCGD7tEQ9jistw40QhAJfBZNc3N/Z+/hZI9XecvafQzJVfRhgm1G0DXU08HjaomIaZbI EEp4kUYYReuZhfQuKIe0d7xHUi4MpInOEIKlRX1qf1997qjH53lPaETKgoxa75WZ9g+07GktM E02hsi2EK1xcd5E6WmkuDbxn5b8gU9kgvnI7kAqcIvpaotuLqXwYRV8DZOPhiOAyb22ZeFuX6 pGEDzfzqCbzipM5TFLIWJX8c71IWlFyllZmE+kwsjL7yomh60pLoJocJDNKraQSZrL++df+iK 6b9nEYJEbNxKm68NZnE0RVIXGSOdYTAjv9+JafN85VHqkdcrsdcbKxZKL56ATd0FepgdPE3kN ErqD0BaCnjFatEyY7harNhqcH1ekGJQw/M6ga0gUM26r1kllDV/b3nNZpBvNlga0NR5Ya24eK lYjL0OhsjXGfy73WNu/IK8sbp9pdlkD/S0qMT2h30a+MIAy/j0CC89HGjlaWY9rvUC+qIzpes VQ7UlMtyaS8a7K7TXLkFcDFEXF1SLyZrzVIb4flD0hF6SBJMExXpnALDfP6NaGuPife+ryzmd uJaUC6KV3kBF34kxkyoHmEQbZYo= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Build argument list and environment of child processes by using struct child_process and populating its members "args" and "env" directly instead of maintaining separate strvecs and letting run_command_v_opt() and friends populate these members. This is simpler, shorter and slightly more efficient. Signed-off-by: René Scharfe --- add-interactive.c | 9 ++- builtin/add.c | 19 +++-- builtin/bisect--helper.c | 35 +++++----- builtin/clone.c | 33 ++++----- builtin/gc.c | 14 ++-- builtin/merge.c | 10 +-- builtin/pull.c | 147 +++++++++++++++++++-------------------- builtin/remote.c | 26 ++++--- diff.c | 27 ++++--- git.c | 15 ++-- merge.c | 18 ++--- scalar.c | 13 ++-- sequencer.c | 25 +++---- 13 files changed, 185 insertions(+), 206 deletions(-) -- 2.38.1 diff --git a/add-interactive.c b/add-interactive.c index f071b2a1b4..ecc5ae1b24 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -997,18 +997,17 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps, count = list_and_choose(s, files, opts); opts->flags = 0; if (count > 0) { - struct strvec args = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; - strvec_pushl(&args, "git", "diff", "-p", "--cached", + strvec_pushl(&cmd.args, "git", "diff", "-p", "--cached", oid_to_hex(!is_initial ? &oid : s->r->hash_algo->empty_tree), "--", NULL); for (i = 0; i < files->items.nr; i++) if (files->selected[i]) - strvec_push(&args, + strvec_push(&cmd.args, files->items.items[i].string); - res = run_command_v_opt(args.v, 0); - strvec_clear(&args); + res = run_command(&cmd); } putchar('\n'); diff --git a/builtin/add.c b/builtin/add.c index f84372964c..626c71ec6a 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -240,8 +240,8 @@ static int refresh(int verbose, const struct pathspec *pathspec) int run_add_interactive(const char *revision, const char *patch_mode, const struct pathspec *pathspec) { - int status, i; - struct strvec argv = STRVEC_INIT; + int i; + struct child_process cmd = CHILD_PROCESS_INIT; int use_builtin_add_i = git_env_bool("GIT_TEST_ADD_I_USE_BUILTIN", -1); @@ -272,19 +272,18 @@ int run_add_interactive(const char *revision, const char *patch_mode, return !!run_add_p(the_repository, mode, revision, pathspec); } - strvec_push(&argv, "add--interactive"); + strvec_push(&cmd.args, "add--interactive"); if (patch_mode) - strvec_push(&argv, patch_mode); + strvec_push(&cmd.args, patch_mode); if (revision) - strvec_push(&argv, revision); - strvec_push(&argv, "--"); + strvec_push(&cmd.args, revision); + strvec_push(&cmd.args, "--"); for (i = 0; i < pathspec->nr; i++) /* pass original pathspec, to be re-parsed */ - strvec_push(&argv, pathspec->items[i].original); + strvec_push(&cmd.args, pathspec->items[i].original); - status = run_command_v_opt(argv.v, RUN_GIT_CMD); - strvec_clear(&argv); - return status; + cmd.git_cmd = 1; + return run_command(&cmd); } int interactive_add(const char **argv, const char *prefix, int patch) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 70d1e9d1ad..5c63ba6994 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -220,18 +220,17 @@ static int bisect_reset(const char *commit) } if (!ref_exists("BISECT_HEAD")) { - struct strvec argv = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; - strvec_pushl(&argv, "checkout", branch.buf, "--", NULL); - if (run_command_v_opt(argv.v, RUN_GIT_CMD)) { + cmd.git_cmd = 1; + strvec_pushl(&cmd.args, "checkout", branch.buf, "--", NULL); + if (run_command(&cmd)) { error(_("could not check out original" " HEAD '%s'. Try 'git bisect" " reset '."), branch.buf); strbuf_release(&branch); - strvec_clear(&argv); return -1; } - strvec_clear(&argv); } strbuf_release(&branch); @@ -1098,40 +1097,38 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc) { - struct strvec args = STRVEC_INIT; - int flags = RUN_COMMAND_NO_STDIN, res = 0; + struct child_process cmd = CHILD_PROCESS_INIT; struct strbuf sb = STRBUF_INIT; if (bisect_next_check(terms, NULL) != 0) return BISECT_FAILED; + cmd.no_stdin = 1; if (!argc) { if ((getenv("DISPLAY") || getenv("SESSIONNAME") || getenv("MSYSTEM") || getenv("SECURITYSESSIONID")) && exists_in_PATH("gitk")) { - strvec_push(&args, "gitk"); + strvec_push(&cmd.args, "gitk"); } else { - strvec_push(&args, "log"); - flags |= RUN_GIT_CMD; + strvec_push(&cmd.args, "log"); + cmd.git_cmd = 1; } } else { if (argv[0][0] == '-') { - strvec_push(&args, "log"); - flags |= RUN_GIT_CMD; + strvec_push(&cmd.args, "log"); + cmd.git_cmd = 1; } else if (strcmp(argv[0], "tig") && !starts_with(argv[0], "git")) - flags |= RUN_GIT_CMD; + cmd.git_cmd = 1; - strvec_pushv(&args, argv); + strvec_pushv(&cmd.args, argv); } - strvec_pushl(&args, "--bisect", "--", NULL); + strvec_pushl(&cmd.args, "--bisect", "--", NULL); strbuf_read_file(&sb, git_path_bisect_names(), 0); - sq_dequote_to_strvec(sb.buf, &args); + sq_dequote_to_strvec(sb.buf, &cmd.args); strbuf_release(&sb); - res = run_command_v_opt(args.v, flags); - strvec_clear(&args); - return res; + return run_command(&cmd); } static int get_first_good(const char *refname UNUSED, diff --git a/builtin/clone.c b/builtin/clone.c index 547d6464b3..56e7775dae 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -653,9 +653,9 @@ static void update_head(const struct ref *our, const struct ref *remote, static int git_sparse_checkout_init(const char *repo) { - struct strvec argv = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; int result = 0; - strvec_pushl(&argv, "-C", repo, "sparse-checkout", "set", NULL); + strvec_pushl(&cmd.args, "-C", repo, "sparse-checkout", "set", NULL); /* * We must apply the setting in the current process @@ -663,12 +663,12 @@ static int git_sparse_checkout_init(const char *repo) */ core_apply_sparse_checkout = 1; - if (run_command_v_opt(argv.v, RUN_GIT_CMD)) { + cmd.git_cmd = 1; + if (run_command(&cmd)) { error(_("failed to initialize sparse-checkout")); result = 1; } - strvec_clear(&argv); return result; } @@ -733,37 +733,38 @@ static int checkout(int submodule_progress, int filter_submodules) oid_to_hex(&oid), "1", NULL); if (!err && (option_recurse_submodules.nr > 0)) { - struct strvec args = STRVEC_INIT; - strvec_pushl(&args, "submodule", "update", "--require-init", "--recursive", NULL); + struct child_process cmd = CHILD_PROCESS_INIT; + strvec_pushl(&cmd.args, "submodule", "update", "--require-init", + "--recursive", NULL); if (option_shallow_submodules == 1) - strvec_push(&args, "--depth=1"); + strvec_push(&cmd.args, "--depth=1"); if (max_jobs != -1) - strvec_pushf(&args, "--jobs=%d", max_jobs); + strvec_pushf(&cmd.args, "--jobs=%d", max_jobs); if (submodule_progress) - strvec_push(&args, "--progress"); + strvec_push(&cmd.args, "--progress"); if (option_verbosity < 0) - strvec_push(&args, "--quiet"); + strvec_push(&cmd.args, "--quiet"); if (option_remote_submodules) { - strvec_push(&args, "--remote"); - strvec_push(&args, "--no-fetch"); + strvec_push(&cmd.args, "--remote"); + strvec_push(&cmd.args, "--no-fetch"); } if (filter_submodules && filter_options.choice) - strvec_pushf(&args, "--filter=%s", + strvec_pushf(&cmd.args, "--filter=%s", expand_list_objects_filter_spec(&filter_options)); if (option_single_branch >= 0) - strvec_push(&args, option_single_branch ? + strvec_push(&cmd.args, option_single_branch ? "--single-branch" : "--no-single-branch"); - err = run_command_v_opt(args.v, RUN_GIT_CMD); - strvec_clear(&args); + cmd.git_cmd = 1; + err = run_command(&cmd); } return err; diff --git a/builtin/gc.c b/builtin/gc.c index 243ee85d28..87ad0077d8 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1910,20 +1910,16 @@ static char *schtasks_task_name(const char *frequency) static int schtasks_remove_task(enum schedule_priority schedule) { const char *cmd = "schtasks"; - int result; - struct strvec args = STRVEC_INIT; + struct child_process child = CHILD_PROCESS_INIT; const char *frequency = get_frequency(schedule); char *name = schtasks_task_name(frequency); get_schedule_cmd(&cmd, NULL); - strvec_split(&args, cmd); - strvec_pushl(&args, "/delete", "/tn", name, "/f", NULL); - - result = run_command_v_opt(args.v, 0); - - strvec_clear(&args); + strvec_split(&child.args, cmd); + strvec_pushl(&child.args, "/delete", "/tn", name, "/f", NULL); free(name); - return result; + + return run_command(&child); } static int schtasks_remove_tasks(void) diff --git a/builtin/merge.c b/builtin/merge.c index 3bb49d805b..864808f51a 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -380,22 +380,22 @@ static void reset_hard(const struct object_id *oid) static void restore_state(const struct object_id *head, const struct object_id *stash) { - struct strvec args = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; reset_hard(head); if (is_null_oid(stash)) goto refresh_cache; - strvec_pushl(&args, "stash", "apply", "--index", "--quiet", NULL); - strvec_push(&args, oid_to_hex(stash)); + strvec_pushl(&cmd.args, "stash", "apply", "--index", "--quiet", NULL); + strvec_push(&cmd.args, oid_to_hex(stash)); /* * It is OK to ignore error here, for example when there was * nothing to restore. */ - run_command_v_opt(args.v, RUN_GIT_CMD); - strvec_clear(&args); + cmd.git_cmd = 1; + run_command(&cmd); refresh_cache: if (discard_cache() < 0 || read_cache() < 0) diff --git a/builtin/pull.c b/builtin/pull.c index 403a24d7ca..b21edd767a 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -515,76 +515,75 @@ static void parse_repo_refspecs(int argc, const char **argv, const char **repo, */ static int run_fetch(const char *repo, const char **refspecs) { - struct strvec args = STRVEC_INIT; - int ret; + struct child_process cmd = CHILD_PROCESS_INIT; - strvec_pushl(&args, "fetch", "--update-head-ok", NULL); + strvec_pushl(&cmd.args, "fetch", "--update-head-ok", NULL); /* Shared options */ - argv_push_verbosity(&args); + argv_push_verbosity(&cmd.args); if (opt_progress) - strvec_push(&args, opt_progress); + strvec_push(&cmd.args, opt_progress); /* Options passed to git-fetch */ if (opt_all) - strvec_push(&args, opt_all); + strvec_push(&cmd.args, opt_all); if (opt_append) - strvec_push(&args, opt_append); + strvec_push(&cmd.args, opt_append); if (opt_upload_pack) - strvec_push(&args, opt_upload_pack); - argv_push_force(&args); + strvec_push(&cmd.args, opt_upload_pack); + argv_push_force(&cmd.args); if (opt_tags) - strvec_push(&args, opt_tags); + strvec_push(&cmd.args, opt_tags); if (opt_prune) - strvec_push(&args, opt_prune); + strvec_push(&cmd.args, opt_prune); if (recurse_submodules_cli != RECURSE_SUBMODULES_DEFAULT) switch (recurse_submodules_cli) { case RECURSE_SUBMODULES_ON: - strvec_push(&args, "--recurse-submodules=on"); + strvec_push(&cmd.args, "--recurse-submodules=on"); break; case RECURSE_SUBMODULES_OFF: - strvec_push(&args, "--recurse-submodules=no"); + strvec_push(&cmd.args, "--recurse-submodules=no"); break; case RECURSE_SUBMODULES_ON_DEMAND: - strvec_push(&args, "--recurse-submodules=on-demand"); + strvec_push(&cmd.args, "--recurse-submodules=on-demand"); break; default: BUG("submodule recursion option not understood"); } if (max_children) - strvec_push(&args, max_children); + strvec_push(&cmd.args, max_children); if (opt_dry_run) - strvec_push(&args, "--dry-run"); + strvec_push(&cmd.args, "--dry-run"); if (opt_keep) - strvec_push(&args, opt_keep); + strvec_push(&cmd.args, opt_keep); if (opt_depth) - strvec_push(&args, opt_depth); + strvec_push(&cmd.args, opt_depth); if (opt_unshallow) - strvec_push(&args, opt_unshallow); + strvec_push(&cmd.args, opt_unshallow); if (opt_update_shallow) - strvec_push(&args, opt_update_shallow); + strvec_push(&cmd.args, opt_update_shallow); if (opt_refmap) - strvec_push(&args, opt_refmap); + strvec_push(&cmd.args, opt_refmap); if (opt_ipv4) - strvec_push(&args, opt_ipv4); + strvec_push(&cmd.args, opt_ipv4); if (opt_ipv6) - strvec_push(&args, opt_ipv6); + strvec_push(&cmd.args, opt_ipv6); if (opt_show_forced_updates > 0) - strvec_push(&args, "--show-forced-updates"); + strvec_push(&cmd.args, "--show-forced-updates"); else if (opt_show_forced_updates == 0) - strvec_push(&args, "--no-show-forced-updates"); + strvec_push(&cmd.args, "--no-show-forced-updates"); if (set_upstream) - strvec_push(&args, set_upstream); - strvec_pushv(&args, opt_fetch.v); + strvec_push(&cmd.args, set_upstream); + strvec_pushv(&cmd.args, opt_fetch.v); if (repo) { - strvec_push(&args, repo); - strvec_pushv(&args, refspecs); + strvec_push(&cmd.args, repo); + strvec_pushv(&cmd.args, refspecs); } else if (*refspecs) BUG("refspecs without repo?"); - ret = run_command_v_opt(args.v, RUN_GIT_CMD | RUN_CLOSE_OBJECT_STORE); - strvec_clear(&args); - return ret; + cmd.git_cmd = 1; + cmd.close_object_store = 1; + return run_command(&cmd); } /** @@ -653,52 +652,50 @@ static int update_submodules(void) */ static int run_merge(void) { - int ret; - struct strvec args = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; - strvec_pushl(&args, "merge", NULL); + strvec_pushl(&cmd.args, "merge", NULL); /* Shared options */ - argv_push_verbosity(&args); + argv_push_verbosity(&cmd.args); if (opt_progress) - strvec_push(&args, opt_progress); + strvec_push(&cmd.args, opt_progress); /* Options passed to git-merge */ if (opt_diffstat) - strvec_push(&args, opt_diffstat); + strvec_push(&cmd.args, opt_diffstat); if (opt_log) - strvec_push(&args, opt_log); + strvec_push(&cmd.args, opt_log); if (opt_signoff) - strvec_push(&args, opt_signoff); + strvec_push(&cmd.args, opt_signoff); if (opt_squash) - strvec_push(&args, opt_squash); + strvec_push(&cmd.args, opt_squash); if (opt_commit) - strvec_push(&args, opt_commit); + strvec_push(&cmd.args, opt_commit); if (opt_edit) - strvec_push(&args, opt_edit); + strvec_push(&cmd.args, opt_edit); if (cleanup_arg) - strvec_pushf(&args, "--cleanup=%s", cleanup_arg); + strvec_pushf(&cmd.args, "--cleanup=%s", cleanup_arg); if (opt_ff) - strvec_push(&args, opt_ff); + strvec_push(&cmd.args, opt_ff); if (opt_verify) - strvec_push(&args, opt_verify); + strvec_push(&cmd.args, opt_verify); if (opt_verify_signatures) - strvec_push(&args, opt_verify_signatures); - strvec_pushv(&args, opt_strategies.v); - strvec_pushv(&args, opt_strategy_opts.v); + strvec_push(&cmd.args, opt_verify_signatures); + strvec_pushv(&cmd.args, opt_strategies.v); + strvec_pushv(&cmd.args, opt_strategy_opts.v); if (opt_gpg_sign) - strvec_push(&args, opt_gpg_sign); + strvec_push(&cmd.args, opt_gpg_sign); if (opt_autostash == 0) - strvec_push(&args, "--no-autostash"); + strvec_push(&cmd.args, "--no-autostash"); else if (opt_autostash == 1) - strvec_push(&args, "--autostash"); + strvec_push(&cmd.args, "--autostash"); if (opt_allow_unrelated_histories > 0) - strvec_push(&args, "--allow-unrelated-histories"); + strvec_push(&cmd.args, "--allow-unrelated-histories"); - strvec_push(&args, "FETCH_HEAD"); - ret = run_command_v_opt(args.v, RUN_GIT_CMD); - strvec_clear(&args); - return ret; + strvec_push(&cmd.args, "FETCH_HEAD"); + cmd.git_cmd = 1; + return run_command(&cmd); } /** @@ -879,43 +876,41 @@ static int get_rebase_newbase_and_upstream(struct object_id *newbase, static int run_rebase(const struct object_id *newbase, const struct object_id *upstream) { - int ret; - struct strvec args = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; - strvec_push(&args, "rebase"); + strvec_push(&cmd.args, "rebase"); /* Shared options */ - argv_push_verbosity(&args); + argv_push_verbosity(&cmd.args); /* Options passed to git-rebase */ if (opt_rebase == REBASE_MERGES) - strvec_push(&args, "--rebase-merges"); + strvec_push(&cmd.args, "--rebase-merges"); else if (opt_rebase == REBASE_INTERACTIVE) - strvec_push(&args, "--interactive"); + strvec_push(&cmd.args, "--interactive"); if (opt_diffstat) - strvec_push(&args, opt_diffstat); - strvec_pushv(&args, opt_strategies.v); - strvec_pushv(&args, opt_strategy_opts.v); + strvec_push(&cmd.args, opt_diffstat); + strvec_pushv(&cmd.args, opt_strategies.v); + strvec_pushv(&cmd.args, opt_strategy_opts.v); if (opt_gpg_sign) - strvec_push(&args, opt_gpg_sign); + strvec_push(&cmd.args, opt_gpg_sign); if (opt_signoff) - strvec_push(&args, opt_signoff); + strvec_push(&cmd.args, opt_signoff); if (opt_autostash == 0) - strvec_push(&args, "--no-autostash"); + strvec_push(&cmd.args, "--no-autostash"); else if (opt_autostash == 1) - strvec_push(&args, "--autostash"); + strvec_push(&cmd.args, "--autostash"); if (opt_verify_signatures && !strcmp(opt_verify_signatures, "--verify-signatures")) warning(_("ignoring --verify-signatures for rebase")); - strvec_push(&args, "--onto"); - strvec_push(&args, oid_to_hex(newbase)); + strvec_push(&cmd.args, "--onto"); + strvec_push(&cmd.args, oid_to_hex(newbase)); - strvec_push(&args, oid_to_hex(upstream)); + strvec_push(&cmd.args, oid_to_hex(upstream)); - ret = run_command_v_opt(args.v, RUN_GIT_CMD); - strvec_clear(&args); - return ret; + cmd.git_cmd = 1; + return run_command(&cmd); } static int get_can_ff(struct object_id *orig_head, diff --git a/builtin/remote.c b/builtin/remote.c index 910f7b9316..11304c096a 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1508,37 +1508,35 @@ static int update(int argc, const char **argv, const char *prefix) N_("prune remotes after fetching")), OPT_END() }; - struct strvec fetch_argv = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; int default_defined = 0; - int retval; argc = parse_options(argc, argv, prefix, options, builtin_remote_update_usage, PARSE_OPT_KEEP_ARGV0); - strvec_push(&fetch_argv, "fetch"); + strvec_push(&cmd.args, "fetch"); if (prune != -1) - strvec_push(&fetch_argv, prune ? "--prune" : "--no-prune"); + strvec_push(&cmd.args, prune ? "--prune" : "--no-prune"); if (verbose) - strvec_push(&fetch_argv, "-v"); - strvec_push(&fetch_argv, "--multiple"); + strvec_push(&cmd.args, "-v"); + strvec_push(&cmd.args, "--multiple"); if (argc < 2) - strvec_push(&fetch_argv, "default"); + strvec_push(&cmd.args, "default"); for (i = 1; i < argc; i++) - strvec_push(&fetch_argv, argv[i]); + strvec_push(&cmd.args, argv[i]); - if (strcmp(fetch_argv.v[fetch_argv.nr-1], "default") == 0) { + if (strcmp(cmd.args.v[cmd.args.nr-1], "default") == 0) { git_config(get_remote_default, &default_defined); if (!default_defined) { - strvec_pop(&fetch_argv); - strvec_push(&fetch_argv, "--all"); + strvec_pop(&cmd.args); + strvec_push(&cmd.args, "--all"); } } - retval = run_command_v_opt(fetch_argv.v, RUN_GIT_CMD); - strvec_clear(&fetch_argv); - return retval; + cmd.git_cmd = 1; + return run_command(&cmd); } static int remove_all_fetch_refspecs(const char *key) diff --git a/diff.c b/diff.c index 648f6717a5..8451c230d9 100644 --- a/diff.c +++ b/diff.c @@ -4278,35 +4278,34 @@ static void run_external_diff(const char *pgm, const char *xfrm_msg, struct diff_options *o) { - struct strvec argv = STRVEC_INIT; - struct strvec env = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; struct diff_queue_struct *q = &diff_queued_diff; - strvec_push(&argv, pgm); - strvec_push(&argv, name); + strvec_push(&cmd.args, pgm); + strvec_push(&cmd.args, name); if (one && two) { - add_external_diff_name(o->repo, &argv, name, one); + add_external_diff_name(o->repo, &cmd.args, name, one); if (!other) - add_external_diff_name(o->repo, &argv, name, two); + add_external_diff_name(o->repo, &cmd.args, name, two); else { - add_external_diff_name(o->repo, &argv, other, two); - strvec_push(&argv, other); - strvec_push(&argv, xfrm_msg); + add_external_diff_name(o->repo, &cmd.args, other, two); + strvec_push(&cmd.args, other); + strvec_push(&cmd.args, xfrm_msg); } } - strvec_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter); - strvec_pushf(&env, "GIT_DIFF_PATH_TOTAL=%d", q->nr); + strvec_pushf(&cmd.env, "GIT_DIFF_PATH_COUNTER=%d", + ++o->diff_path_counter); + strvec_pushf(&cmd.env, "GIT_DIFF_PATH_TOTAL=%d", q->nr); diff_free_filespec_data(one); diff_free_filespec_data(two); - if (run_command_v_opt_cd_env(argv.v, RUN_USING_SHELL, NULL, env.v)) + cmd.use_shell = 1; + if (run_command(&cmd)) die(_("external diff died, stopping at %s"), name); remove_tempfile(); - strvec_clear(&argv); - strvec_clear(&env); } static int similarity_index(struct diff_filepair *p) diff --git a/git.c b/git.c index ee7758dcb0..6662548986 100644 --- a/git.c +++ b/git.c @@ -787,7 +787,7 @@ static int run_argv(int *argcp, const char ***argv) if (!done_alias) handle_builtin(*argcp, *argv); else if (get_builtin(**argv)) { - struct strvec args = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; int i; /* @@ -804,18 +804,21 @@ static int run_argv(int *argcp, const char ***argv) commit_pager_choice(); - strvec_push(&args, "git"); + strvec_push(&cmd.args, "git"); for (i = 0; i < *argcp; i++) - strvec_push(&args, (*argv)[i]); + strvec_push(&cmd.args, (*argv)[i]); - trace_argv_printf(args.v, "trace: exec:"); + trace_argv_printf(cmd.args.v, "trace: exec:"); /* * if we fail because the command is not found, it is * OK to return. Otherwise, we just pass along the status code. */ - i = run_command_v_opt_tr2(args.v, RUN_SILENT_EXEC_FAILURE | - RUN_CLEAN_ON_EXIT | RUN_WAIT_AFTER_CLEAN, "git_alias"); + cmd.silent_exec_failure = 1; + cmd.clean_on_exit = 1; + cmd.wait_after_clean = 1; + cmd.trace2_child_class = "git_alias"; + i = run_command(&cmd); if (i >= 0 || errno != ENOENT) exit(i); die("could not execute builtin %s", **argv); diff --git a/merge.c b/merge.c index 2382ff66d3..445b4f19aa 100644 --- a/merge.c +++ b/merge.c @@ -19,22 +19,22 @@ int try_merge_command(struct repository *r, const char **xopts, struct commit_list *common, const char *head_arg, struct commit_list *remotes) { - struct strvec args = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; int i, ret; struct commit_list *j; - strvec_pushf(&args, "merge-%s", strategy); + strvec_pushf(&cmd.args, "merge-%s", strategy); for (i = 0; i < xopts_nr; i++) - strvec_pushf(&args, "--%s", xopts[i]); + strvec_pushf(&cmd.args, "--%s", xopts[i]); for (j = common; j; j = j->next) - strvec_push(&args, merge_argument(j->item)); - strvec_push(&args, "--"); - strvec_push(&args, head_arg); + strvec_push(&cmd.args, merge_argument(j->item)); + strvec_push(&cmd.args, "--"); + strvec_push(&cmd.args, head_arg); for (j = remotes; j; j = j->next) - strvec_push(&args, merge_argument(j->item)); + strvec_push(&cmd.args, merge_argument(j->item)); - ret = run_command_v_opt(args.v, RUN_GIT_CMD); - strvec_clear(&args); + cmd.git_cmd = 1; + ret = run_command(&cmd); discard_index(r->index); if (repo_read_index(r) < 0) diff --git a/scalar.c b/scalar.c index 6de9c0ee52..03f9e480dd 100644 --- a/scalar.c +++ b/scalar.c @@ -69,21 +69,18 @@ static void setup_enlistment_directory(int argc, const char **argv, static int run_git(const char *arg, ...) { - struct strvec argv = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; va_list args; const char *p; - int res; va_start(args, arg); - strvec_push(&argv, arg); + strvec_push(&cmd.args, arg); while ((p = va_arg(args, const char *))) - strvec_push(&argv, p); + strvec_push(&cmd.args, p); va_end(args); - res = run_command_v_opt(argv.v, RUN_GIT_CMD); - - strvec_clear(&argv); - return res; + cmd.git_cmd = 1; + return run_command(&cmd); } struct scalar_config { diff --git a/sequencer.c b/sequencer.c index debb2ecbaf..8ab0225f0f 100644 --- a/sequencer.c +++ b/sequencer.c @@ -3183,18 +3183,15 @@ static int rollback_is_safe(void) static int reset_merge(const struct object_id *oid) { - int ret; - struct strvec argv = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; - strvec_pushl(&argv, "reset", "--merge", NULL); + cmd.git_cmd = 1; + strvec_pushl(&cmd.args, "reset", "--merge", NULL); if (!is_null_oid(oid)) - strvec_push(&argv, oid_to_hex(oid)); + strvec_push(&cmd.args, oid_to_hex(oid)); - ret = run_command_v_opt(argv.v, RUN_GIT_CMD); - strvec_clear(&argv); - - return ret; + return run_command(&cmd); } static int rollback_single_pick(struct repository *r) @@ -4867,14 +4864,14 @@ static int pick_commits(struct repository *r, static int continue_single_pick(struct repository *r, struct replay_opts *opts) { - struct strvec argv = STRVEC_INIT; - int ret; + struct child_process cmd = CHILD_PROCESS_INIT; if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") && !refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) return error(_("no cherry-pick or revert in progress")); - strvec_push(&argv, "commit"); + cmd.git_cmd = 1; + strvec_push(&cmd.args, "commit"); /* * continue_single_pick() handles the case of recovering from a @@ -4887,11 +4884,9 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts) * Include --cleanup=strip as well because we don't want the * "# Conflicts:" messages. */ - strvec_pushl(&argv, "--no-edit", "--cleanup=strip", NULL); + strvec_pushl(&cmd.args, "--no-edit", "--cleanup=strip", NULL); - ret = run_command_v_opt(argv.v, RUN_GIT_CMD); - strvec_clear(&argv); - return ret; + return run_command(&cmd); } static int commit_staged_changes(struct repository *r, From patchwork Thu Oct 27 16:37:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13022371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F76DFA3740 for ; Thu, 27 Oct 2022 16:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235052AbiJ0QiH (ORCPT ); Thu, 27 Oct 2022 12:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236551AbiJ0QiD (ORCPT ); Thu, 27 Oct 2022 12:38:03 -0400 Received: from mout.web.de (mout.web.de [212.227.15.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC79218F252 for ; Thu, 27 Oct 2022 09:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1666888672; bh=Hd1uKT5Cbyz8k2lJ87VTZTu036aj2FQ2N42BtpzXwSw=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=tR5YX03131p/UfBjm6VtthTMr1fQOfoTAIDfOWWkSy5RZoO+XaUZaEOpPlh+Xofp9 vY5+LTKJRwI6L9GczC9+Z0RhH1nb6TklGiR+F1YQbxStF0K/6dwU8eghwLzHcfUR+I 9UeFDTuLWtHRC7e7UE6sqwXIX0wLFOcek1Fvmw78WorfJWW5ijP5OFbjrmeBS8baKT vYRPGOIoUpDGmXcWN5SuSNSUl6OcTTDRWEuPqtaHZVEWdhHvrcZI7msPqwMIXycI76 nrmVMExdhZq/WKsc4aSzpenkTvW0NlZd1YB1Wyezcdfp7xCMblj52AhFgznyHaoKRU uYg9bLxjTd9Tg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.23.191]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MjBRZ-1pK7C12smj-00f7RT; Thu, 27 Oct 2022 18:37:52 +0200 Message-ID: <0e889c96-6004-96e4-9505-19ce1e7f9900@web.de> Date: Thu, 27 Oct 2022 18:37:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH 4/8] use child_process member "args" instead of string array variable Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git List Cc: Junio C Hamano , Taylor Blau , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= References: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> In-Reply-To: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> X-Provags-ID: V03:K1:RGmmrzX2WJ+EWyl3Kv0f4YOIqdl72zm+kfpInyM7AF8dv7gAl+k c35WF5IaA0D3DqFUKRsPal+9xmljx7v0MdfHxYObiYynkrmjDzhxXK3UYknfOSZY2KWYX/W uzYTr1d1i9m3Pk87tWkYEuQNvkk9di4ElKhpu+ow3VBZ+K44HZdeSqUooIzHW35I5A4B4px CB14VI+Y3SWVo1md0uhaA== UI-OutboundReport: notjunk:1;M01:P0:ScaiSMadREI=;Ib3Ka0/nYfoBydWCmy7IL111LG2 3L1PdztKUiBQBrX94YUtEKlKVp9OAsRH9xeqJA6o/X/mJWrGMpUxMbntcVhiABHi7ynRRqs7I QBwnnkPMyhiZ4joxr9ZSM+pI6N9dm0h+xFdZ7lXXT5SHGAvNH4Y//5GuD9PdnjW1kevUL/WrW 6bbs7XqHetr1/1qQzfFleapyKX+7P22ihBc3Rtr5cJ42/EwvVvlu0XMRqJnIpWD1dfMH9ax+r 6ATqx2ZHMZyf9lZTKtPoy/sww0j7X9A4gWTteVY5zzyLYV9TVWps5t8ngLMfvj7RQ449iVDIr EBybfCW+UwewAR03vRKakJ6/v8L/6vuwHdJl91pNAdL2cwXyoHjDSE7m5uTefEJWZ+AUEnVAG YS0C92ADdthXLYHUHbYcfN66BJ9Vj+kCMg8Tgc8I6R0pUNYpnzBEN4cJ0hoAMX6EgdJvTzUbG pL/6DlrmRnmBkc1PNlu9WSHgngYKBMhGfdot2kjSEs9sOQ/zeosSon9hxXMrNjUaP9uqBE0/l +Ei95nBe1RmeccHSJo4dJBpZajIDJjY4l+Xt8ExTFqqSEjt+3I5J4ziuCEs78FLGKrn4CueeO lZ3LtFCJou4sZuCtdNBYU9MV4oVBtoG2pta/DDrHiZ2a+burF16qbcfUD2y7aL/6E9qtPqm1G G7+LdEZGpDkjGpYxTO9T8X+iUCgZecikqAriIz+/HXViqz8LlTdv00tnpuvJInJ5n9G/9px03 iEgTUauWZNNvKvVYzlq6KyWjpE3qfkfTWIpQ/TEGsVq1eD1dyDCjSej9PwDwMluFfm6+HmEJ6 7rXmwsxwcaYQrO7qpPkcxLJhG10yWrlUSS/r1OCQkLDTvxlpJmPM9EwsK4HcJjb51Oh8vYXxV bjD8hvnqYGdEa1V2B7c3J2AEd1UHd7Lf6KYC5463rXJW4f0rQZeiqvMDFJAHMt/+ut22g0wHC OpNUB/H82yjAiUaCh7jXYakG9Ls= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Use run_command() with a struct child_process variable and populate its "args" member directly instead of building a string array and passing it to run_command_v_opt(). This avoids the use of magic index numbers. Signed-off-by: René Scharfe --- bisect.c | 12 ++++++------ builtin/am.c | 12 +++++------- builtin/difftool.c | 17 +++++++++-------- builtin/merge.c | 32 ++++++++++++-------------------- builtin/remote.c | 14 ++++++++------ compat/mingw.c | 11 +++++++---- ll-merge.c | 7 ++++--- sequencer.c | 7 ++++--- t/helper/test-fake-ssh.c | 7 ++++--- 9 files changed, 59 insertions(+), 60 deletions(-) -- 2.38.1 diff --git a/bisect.c b/bisect.c index fd581b85a7..ec7487e683 100644 --- a/bisect.c +++ b/bisect.c @@ -22,8 +22,6 @@ static struct oid_array skipped_revs; static struct object_id *current_bad_oid; -static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL}; - static const char *term_bad; static const char *term_good; @@ -729,20 +727,22 @@ static int is_expected_rev(const struct object_id *oid) enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int no_checkout) { - char bisect_rev_hex[GIT_MAX_HEXSZ + 1]; struct commit *commit; struct pretty_print_context pp = {0}; struct strbuf commit_msg = STRBUF_INIT; - oid_to_hex_r(bisect_rev_hex, bisect_rev); update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR); - argv_checkout[2] = bisect_rev_hex; if (no_checkout) { update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR); } else { - if (run_command_v_opt(argv_checkout, RUN_GIT_CMD)) + struct child_process cmd = CHILD_PROCESS_INIT; + + cmd.git_cmd = 1; + strvec_pushl(&cmd.args, "checkout", "-q", + oid_to_hex(bisect_rev), "--", NULL); + if (run_command(&cmd)) /* * Errors in `run_command()` itself, signaled by res < 0, * and errors in the child process, signaled by res > 0 diff --git a/builtin/am.c b/builtin/am.c index 39fea24833..20aea0d248 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -2187,14 +2187,12 @@ static int show_patch(struct am_state *state, enum show_patch_type sub_mode) int len; if (!is_null_oid(&state->orig_commit)) { - const char *av[4] = { "show", NULL, "--", NULL }; - char *new_oid_str; - int ret; + struct child_process cmd = CHILD_PROCESS_INIT; - av[1] = new_oid_str = xstrdup(oid_to_hex(&state->orig_commit)); - ret = run_command_v_opt(av, RUN_GIT_CMD); - free(new_oid_str); - return ret; + strvec_pushl(&cmd.args, "show", oid_to_hex(&state->orig_commit), + "--", NULL); + cmd.git_cmd = 1; + return run_command(&cmd); } switch (sub_mode) { diff --git a/builtin/difftool.c b/builtin/difftool.c index 4b10ad1a36..22bcc3444b 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -360,8 +360,8 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix, struct pair_entry *entry; struct index_state wtindex; struct checkout lstate, rstate; - int flags = RUN_GIT_CMD, err = 0; - const char *helper_argv[] = { "difftool--helper", NULL, NULL, NULL }; + int err = 0; + struct child_process cmd = CHILD_PROCESS_INIT; struct hashmap wt_modified, tmp_modified; int indices_loaded = 0; @@ -563,16 +563,17 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix, } strbuf_setlen(&ldir, ldir_len); - helper_argv[1] = ldir.buf; strbuf_setlen(&rdir, rdir_len); - helper_argv[2] = rdir.buf; if (extcmd) { - helper_argv[0] = extcmd; - flags = 0; - } else + strvec_push(&cmd.args, extcmd); + } else { + strvec_push(&cmd.args, "difftool--helper"); + cmd.git_cmd = 1; setenv("GIT_DIFFTOOL_DIRDIFF", "true", 1); - ret = run_command_v_opt(helper_argv, flags); + } + strvec_pushl(&cmd.args, ldir.buf, rdir.buf, NULL); + ret = run_command(&cmd); /* TODO: audit for interaction with sparse-index. */ ensure_full_index(&wtindex); diff --git a/builtin/merge.c b/builtin/merge.c index 864808f51a..b3f75f55c8 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -347,33 +347,25 @@ static int save_state(struct object_id *stash) static void read_empty(const struct object_id *oid) { - int i = 0; - const char *args[7]; - - args[i++] = "read-tree"; - args[i++] = "-m"; - args[i++] = "-u"; - args[i++] = empty_tree_oid_hex(); - args[i++] = oid_to_hex(oid); - args[i] = NULL; + struct child_process cmd = CHILD_PROCESS_INIT; + + strvec_pushl(&cmd.args, "read-tree", "-m", "-u", empty_tree_oid_hex(), + oid_to_hex(oid), NULL); + cmd.git_cmd = 1; - if (run_command_v_opt(args, RUN_GIT_CMD)) + if (run_command(&cmd)) die(_("read-tree failed")); } static void reset_hard(const struct object_id *oid) { - int i = 0; - const char *args[6]; - - args[i++] = "read-tree"; - args[i++] = "-v"; - args[i++] = "--reset"; - args[i++] = "-u"; - args[i++] = oid_to_hex(oid); - args[i] = NULL; + struct child_process cmd = CHILD_PROCESS_INIT; + + strvec_pushl(&cmd.args, "read-tree", "-v", "--reset", "-u", + oid_to_hex(oid), NULL); + cmd.git_cmd = 1; - if (run_command_v_opt(args, RUN_GIT_CMD)) + if (run_command(&cmd)) die(_("read-tree failed")); } diff --git a/builtin/remote.c b/builtin/remote.c index 11304c096a..12632676cd 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -92,13 +92,15 @@ static int verbose; static int fetch_remote(const char *name) { - const char *argv[] = { "fetch", name, NULL, NULL }; - if (verbose) { - argv[1] = "-v"; - argv[2] = name; - } + struct child_process cmd = CHILD_PROCESS_INIT; + + strvec_push(&cmd.args, "fetch"); + if (verbose) + strvec_push(&cmd.args, "-v"); + strvec_push(&cmd.args, name); + cmd.git_cmd = 1; printf_ln(_("Updating %s"), name); - if (run_command_v_opt(argv, RUN_GIT_CMD)) + if (run_command(&cmd)) return error(_("Could not fetch %s"), name); return 0; } diff --git a/compat/mingw.c b/compat/mingw.c index 901375d584..d614f156df 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -196,16 +196,19 @@ static int read_yes_no_answer(void) static int ask_yes_no_if_possible(const char *format, ...) { char question[4096]; - const char *retry_hook[] = { NULL, NULL, NULL }; + const char *retry_hook; va_list args; va_start(args, format); vsnprintf(question, sizeof(question), format, args); va_end(args); - if ((retry_hook[0] = mingw_getenv("GIT_ASK_YESNO"))) { - retry_hook[1] = question; - return !run_command_v_opt(retry_hook, 0); + retry_hook = mingw_getenv("GIT_ASK_YESNO"); + if (retry_hook) { + struct child_process cmd = CHILD_PROCESS_INIT; + + strvec_pushl(&cmd.args, retry_hook, question, NULL); + return !run_command(&cmd); } if (!isatty(_fileno(stdin)) || !isatty(_fileno(stderr))) diff --git a/ll-merge.c b/ll-merge.c index 8955d7e1f6..d5f0c62bd8 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -193,7 +193,7 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn, struct strbuf cmd = STRBUF_INIT; struct strbuf_expand_dict_entry dict[6]; struct strbuf path_sq = STRBUF_INIT; - const char *args[] = { NULL, NULL }; + struct child_process child = CHILD_PROCESS_INIT; int status, fd, i; struct stat st; enum ll_merge_result ret; @@ -219,8 +219,9 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn, strbuf_expand(&cmd, fn->cmdline, strbuf_expand_dict_cb, &dict); - args[0] = cmd.buf; - status = run_command_v_opt(args, RUN_USING_SHELL); + child.use_shell = 1; + strvec_push(&child.args, cmd.buf); + status = run_command(&child); fd = open(temp[1], O_RDONLY); if (fd < 0) goto bad; diff --git a/sequencer.c b/sequencer.c index 8ab0225f0f..643744fb9b 100644 --- a/sequencer.c +++ b/sequencer.c @@ -3555,12 +3555,13 @@ static int error_failed_squash(struct repository *r, static int do_exec(struct repository *r, const char *command_line) { - const char *child_argv[] = { NULL, NULL }; + struct child_process cmd = CHILD_PROCESS_INIT; int dirty, status; fprintf(stderr, _("Executing: %s\n"), command_line); - child_argv[0] = command_line; - status = run_command_v_opt(child_argv, RUN_USING_SHELL); + cmd.use_shell = 1; + strvec_push(&cmd.args, command_line); + status = run_command(&cmd); /* force re-reading of the cache */ if (discard_index(r->index) < 0 || repo_read_index(r) < 0) diff --git a/t/helper/test-fake-ssh.c b/t/helper/test-fake-ssh.c index 12beee99ad..2e576bcc11 100644 --- a/t/helper/test-fake-ssh.c +++ b/t/helper/test-fake-ssh.c @@ -8,7 +8,7 @@ int cmd_main(int argc, const char **argv) struct strbuf buf = STRBUF_INIT; FILE *f; int i; - const char *child_argv[] = { NULL, NULL }; + struct child_process cmd = CHILD_PROCESS_INIT; /* First, print all parameters into $TRASH_DIRECTORY/ssh-output */ if (!trash_directory) @@ -25,6 +25,7 @@ int cmd_main(int argc, const char **argv) /* Now, evaluate the *last* parameter */ if (argc < 2) return 0; - child_argv[0] = argv[argc - 1]; - return run_command_v_opt(child_argv, RUN_USING_SHELL); + cmd.use_shell = 1; + strvec_push(&cmd.args, argv[argc - 1]); + return run_command(&cmd); } From patchwork Thu Oct 27 16:38:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13022372 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2891FA3741 for ; Thu, 27 Oct 2022 16:38:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236452AbiJ0Qiu (ORCPT ); Thu, 27 Oct 2022 12:38:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235105AbiJ0Qit (ORCPT ); Thu, 27 Oct 2022 12:38:49 -0400 Received: from mout.web.de (mout.web.de [212.227.15.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C4C918708A for ; Thu, 27 Oct 2022 09:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1666888722; bh=2P13dpoQKpDKEfMy9keH6WbEiRmKq5S+PicwbVBHZuI=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=tEeT9udQTjcdE/hLLeswAyiYCyAb1ab50V+VDLH/Gxt+sXgLjvbCkWKwV0uFDhnrS p4OTISUJYmiGAPiXItX8Bj/vJFsI6BgYVkAaGqzZuDSDMpDab/OH0G/fR45ryZTs4n WWUJGOdAAqrzsRQZREyy42UE7ulpTgsj24sM1uX5XYrTcRgVWDoIVvMGbbarp2L2Vk +kQ3NA0k13tLdaUv0E4wd6HwDWU+cQd1vPB6QYJfDKqVIhayM90Twpcqr7TCr/Nai8 uv22+O1OTENZG0gRBDYUtCJN9RGyb+fZEMi31qg9PCfRYPCwwyq9tdVES1z5mzs+5l pdE9jBv/F/1xw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.23.191]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N6b8s-1p8KWC0WQo-0180aq; Thu, 27 Oct 2022 18:38:42 +0200 Message-ID: Date: Thu, 27 Oct 2022 18:38:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH 5/8] replace and remove run_command_v_opt_cd_env() Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git List Cc: Junio C Hamano , Taylor Blau , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= References: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> In-Reply-To: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> X-Provags-ID: V03:K1:HY2hWvk98oNy1Yk0JegJ09RtRDorP4yEoLR8gNYNS7jrR3+vSdA 8zqXRZPcxeafl6kYDplZIiosC2L1xOWQmMbtcdfc8s7Sdm/ckzjfKdQpIabqyQLnrZABFlw QrcBXkqNanLRgAhNwhacioOeSMQpdpFgQDIZflept0d+KGS1Uunz847IfQJ5rR8o0uC8c8h HJAMwGKtrdySwiMNMu8mA== UI-OutboundReport: notjunk:1;M01:P0:sVguxXUPKOw=;jmER3pH4j+zd/FgVEiw39sK3kxy 0ctuV7ZmN217h7xW5jpTfpelxh2juv8F4bMYV/pb1h+FvQBPwyJwxTFeQytZz3eIR/oIKHEJH Vde1u5aRuALA5h7ot6CDBCPQoSwq1QcdYK2Kz/oIPL49UF9DXViLrnzuQWUU4thTgYlTSb8vk FsZNppBWbEdHvzy6//Gv5Trrj/8D48UGm7pLNBOuHEHg5vlTIGA//bRMpCQLTOx2t510iJYaA evDNSFuFIoHGqATbuToU9dKnDbEZmMvEG/8Ne/C4zpDPcz7rQ03NbRNnbHDlrRZjDuRwvFjjL fXMJLZ2NB6kIXfErkuqgj8Ebg2Hj8sGXte7QI8ZGnDerNoAGRPq9jyjp7IgkVyCQn3nXa9/7h TlICt/yVI0yyGfty9tcrKOGjx+ncZO98fXIlnEIGD4JYE1y26JwkJ36RIGT+T+6wqZIjRDUdN jj59EcAMS/XYw0uTrfvOk5X7HvQPJtoIhUZVbgFqE4CYlrgijy2DvoG7UiPNr5d1kFmxk3pGa c3BRz3ivtB4D4WAtFPRpUJVkfzyIp0GY0ShLAb+2qzavL8RgItsPsxNkSlSKtbi9rpKj+l/BN tNOsrrIbNPP0ZHYQdxeiKSoimWckTMFChx3N0tNdgoHMyfBxZMYC/vJc0E4toHIvOoch6fctw fXaPSckwFGEbA3PrvO8/rcu+SrFfHRGpQzSNEaGu40FwefuUZNBreZWV89unGTbS3DWOm6p3g mm60324xO5WoYvc58+UuV6QGyJBh834pfzya/r+nyLsPlhSCGGWLUGepkwyMwX2toQw3B8Ojw DqVvazvP/dCvWVrXkaQLTMSNolouQpq9dZ0Tq6g4XzX2+eBamjps4K+BxGi5yeMKOVLN4dZcK E1tFMf70EYOPgzNldwSKNcXY51gmrtTMAudnzXuk0yQ98gCeJV58becCdfdO1POwSFwoo11gW Gn5n1w49MVi/siZnOXBOXkq+5us= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org run_command_v_opt_cd_env() is only used in an example in a comment. Use the struct child_process member "env" and run_command() directly instead and then remove the unused convenience function. Signed-off-by: René Scharfe --- run-command.c | 7 +------ run-command.h | 4 +--- tmp-objdir.h | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) -- 2.38.1 diff --git a/run-command.c b/run-command.c index 5ec3a46dcc..1c9ed510f8 100644 --- a/run-command.c +++ b/run-command.c @@ -1006,7 +1006,7 @@ int run_command(struct child_process *cmd) int run_command_v_opt(const char **argv, int opt) { - return run_command_v_opt_cd_env(argv, opt, NULL, NULL); + return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, NULL); } int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class) @@ -1014,11 +1014,6 @@ int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class) return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, tr2_class); } -int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env) -{ - return run_command_v_opt_cd_env_tr2(argv, opt, dir, env, NULL); -} - int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, const char *const *env, const char *tr2_class) { diff --git a/run-command.h b/run-command.h index 0e85e5846a..a5e210fd1a 100644 --- a/run-command.h +++ b/run-command.h @@ -151,8 +151,7 @@ struct child_process { /** * The functions: child_process_init, start_command, finish_command, - * run_command, run_command_v_opt, run_command_v_opt_cd_env, child_process_clear - * do the following: + * run_command, run_command_v_opt, child_process_clear do the following: * * - If a system call failed, errno is set and -1 is returned. A diagnostic * is printed. @@ -250,7 +249,6 @@ int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class); * env (the environment) is to be formatted like environ: "VAR=VALUE". * To unset an environment variable use just "VAR". */ -int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env); int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, const char *const *env, const char *tr2_class); diff --git a/tmp-objdir.h b/tmp-objdir.h index 76efc7edee..615b188573 100644 --- a/tmp-objdir.h +++ b/tmp-objdir.h @@ -11,8 +11,8 @@ * Example: * * struct tmp_objdir *t = tmp_objdir_create("incoming"); - * if (!run_command_v_opt_cd_env(cmd, 0, NULL, tmp_objdir_env(t)) && - * !tmp_objdir_migrate(t)) + * strvec_pushv(&cmd.env, tmp_objdir_env(t)); + * if (!run_command(&cmd)) && !tmp_objdir_migrate(t)) * printf("success!\n"); * else * die("failed...tmp_objdir will clean up for us"); From patchwork Thu Oct 27 16:39:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13022373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A119BECAAA1 for ; Thu, 27 Oct 2022 16:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235506AbiJ0Qjt (ORCPT ); Thu, 27 Oct 2022 12:39:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235970AbiJ0Qjp (ORCPT ); Thu, 27 Oct 2022 12:39:45 -0400 Received: from mout.web.de (mout.web.de [212.227.15.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB77E13E16 for ; Thu, 27 Oct 2022 09:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1666888769; bh=n99LfgTxiuToT6Jg+NLMc59z8PevqBP9I8mq7sUc6+g=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=sSp6wpkcV+7O+Fp1LJ4nc2Q0NeqKCnw23qMDx3xZATGVJEBfSg7B/KA57q0iqALQS hhOBYk+YRp4vCDTHFNT738tZetE3FbX1NDTMOHwVfwmyirGcpaVELXOpJ8JbXVUz87 /kJfIfGX/aV86No1jevBVuEifefoLbk6cUVD89vtE0mm6C5vHI5ZWRErNeMJ4eZzyr rqWdCdBZaGVOlo8yk4Wr6tB7Kc6eJpt9cThtpIJr60LXefY1hrofKriJ77ZMTDft1X ersIuC13FqPvaAwejNKRiaMgR7Jw/lTVMRpx6EuxBA2WG99jpuXtwiCBQ0t6tS+rQy +3YYvGokFGEJw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.23.191]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MiMEM-1pJHny45qA-00fOco; Thu, 27 Oct 2022 18:39:29 +0200 Message-ID: <65f44b18-b23e-5d1a-2b57-6d326c05f4f5@web.de> Date: Thu, 27 Oct 2022 18:39:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH 6/8] replace and remove run_command_v_opt_tr2() Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git List Cc: Junio C Hamano , Taylor Blau , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= References: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> In-Reply-To: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> X-Provags-ID: V03:K1:TlMGAgyz+fiLt2NYEq2f5YGd4Rp3e0DPe76SjmYzjGa2n98TGKg NouRRzZeJnk7wi3GBubGrUcjxrAfmZu52vXKoivmcz42THMI4u8c1IvyX8joleTBqdhSzBp aDDAcVyQgk2SWmFRcikolitM9JbBIX2qQGUio2iCnpaSwXZSMyrjqYA1CqdEazuXILJhANC o6h/El41o1E7VL3tjg3kA== UI-OutboundReport: notjunk:1;M01:P0:4Zoy7+Q3E7c=;sACHpEts4IttCjJLOrHcLC1FH98 ysebyx2jF4Rv7GtZUBvM17XqmZM80L/q1byv4wccMoAE7eiPSE2LvRbCDix3exQst9o+OzR3I pu/lG2SV4KJ7fs+NXT6VGlwsuoqMq5Dx4CQ1N1mE9k5yX9J4rjtDlf6+/S4TI9FArPOfPAPAN EQ0sOI72w+1RGXP48+T9hhTHIzZMuC9owyb4OPUrYPlM2D8+eASA7nXYmH+GgFRNzkUvh0Qs+ 43xHKlxve9R53OifF5TL00Reml29LXurJjlf3phhdX53DdFf2mJF46sCU+O45kwLK8tqiLl02 G5Hqza60+epZCFZYBSjbG/MVCxMFJDtR9RAVZ5wsQQPbSKOii/ZMn+3cxMPdH/vsVhYQWN6uz xRizcsXjqGFgxuU2qdnvHW0+3GIFR+ZB7Q/YvcA5lM2PbbTNQWarzjjaCVAeZM8MaO6d7H6By BFRUtd47OJHdMcijR1WiUx5oRieGqppDngKIUokCv5O7YtBmL9bGmbMekLUuiXnQPXqaOt7o9 aggufYjuaCFEKgu9QMrcHETRXFmzEXBL7sWbMw/HgGbcO/ZYxki/uvxfJQ00Fn5lOpQh40AKg Yj8Ma51MeID7u4TxEoxsGnCEL8by7v8nCms1ArWPNi7r2oyXrvOtaluMZ05f6zW3cWy89iQwP xQHwGBKSfG9p8xRlTvksjGXfRsgMfyan9lblKizhCRJMQ0CA2NHAj0j7UX5WrH1csdILcffL5 JDyjORqlYDFn2GzdMtjjDki79MSyknA+2fIObrdNB0ieKgRE7m6aJYcZ0hUTi2vxjbe6jUq0z XsJdSWRa7GcXNS9/tjvDr7A9f+UMYv1ytk4qTJP9Ptn0+QsncDdkoZSaeprt6nq8PEnq7fZ6j QrRfkEzBdqBYXWRDHEvRRRSXxABQlQSI000bJtW/awfxdijayhZpxRO7FUW9V6YAPl+GnQMrC /ZeDzq3NlLvF//QcWGUVUP7qdMY= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The convenience function run_command_v_opt_tr2() is only used by a single caller. Use struct child_process and run_command() directly instead and remove the underused function. Signed-off-by: René Scharfe --- fsmonitor-ipc.c | 10 +++++++--- run-command.c | 5 ----- run-command.h | 1 - 3 files changed, 7 insertions(+), 9 deletions(-) -- 2.38.1 diff --git a/fsmonitor-ipc.c b/fsmonitor-ipc.c index c0f42301c8..19d772f0f3 100644 --- a/fsmonitor-ipc.c +++ b/fsmonitor-ipc.c @@ -54,10 +54,14 @@ enum ipc_active_state fsmonitor_ipc__get_state(void) static int spawn_daemon(void) { - const char *args[] = { "fsmonitor--daemon", "start", NULL }; + struct child_process cmd = CHILD_PROCESS_INIT; - return run_command_v_opt_tr2(args, RUN_COMMAND_NO_STDIN | RUN_GIT_CMD, - "fsmonitor"); + cmd.git_cmd = 1; + cmd.no_stdin = 1; + cmd.trace2_child_class = "fsmonitor"; + strvec_pushl(&cmd.args, "fsmonitor--daemon", "start", NULL); + + return run_command(&cmd); } int fsmonitor_ipc__send_query(const char *since_token, diff --git a/run-command.c b/run-command.c index 1c9ed510f8..32fa4b0ed6 100644 --- a/run-command.c +++ b/run-command.c @@ -1009,11 +1009,6 @@ int run_command_v_opt(const char **argv, int opt) return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, NULL); } -int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class) -{ - return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, tr2_class); -} - int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, const char *const *env, const char *tr2_class) { diff --git a/run-command.h b/run-command.h index a5e210fd1a..482da7f60c 100644 --- a/run-command.h +++ b/run-command.h @@ -244,7 +244,6 @@ int run_auto_maintenance(int quiet); * corresponds to the member .env. */ int run_command_v_opt(const char **argv, int opt); -int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class); /* * env (the environment) is to be formatted like environ: "VAR=VALUE". * To unset an environment variable use just "VAR". From patchwork Thu Oct 27 16:40:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13022374 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEB8CFA3740 for ; Thu, 27 Oct 2022 16:40:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235666AbiJ0Qk3 (ORCPT ); Thu, 27 Oct 2022 12:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234730AbiJ0Qk0 (ORCPT ); Thu, 27 Oct 2022 12:40:26 -0400 Received: from mout.web.de (mout.web.de [212.227.15.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21B7E6A49B for ; Thu, 27 Oct 2022 09:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1666888816; bh=cIgRqmfIPkhIt8vmDvIqDHQIItQgwe5viELbamMQzgg=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=rBtbcJQ0tpVJPJZyHrTpWEM4zZwfSHWNbO2ZoS+UJi/WEh1qdGArU64ViE0GH8Qt8 hZDllVgDFCJ6mqueSkNm7w9/Kol9R03YKYDa7PdjJHXG+EfFRfxLIjDHAVWfuUOH3u xWKBau9z10/9MBORi8gLBz3gcEhbUk0iuCc+e0WbkgIL+WRHJ+iRmCFxB8HiML5Ecu lOUflfZA7PV81DUVN34uxk7n6i587bF4x6TWC59LEb2k5p6Sswawx7IWp7Ck5K31eu GvnWz6FVKqaO9O8L/Hi5CcNUpyvlIyzARNBqTYYPkV3lM3mnBPEth15CM6hzP4XF3C E8pmYkmMixQQQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.23.191]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MLzin-1oWq9p060f-00HyPe; Thu, 27 Oct 2022 18:40:16 +0200 Message-ID: Date: Thu, 27 Oct 2022 18:40:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH 7/8] replace and remove run_command_v_opt_cd_env_tr2() Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git List Cc: Junio C Hamano , Taylor Blau , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= References: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> In-Reply-To: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> X-Provags-ID: V03:K1:FBcwbDhjsJXXqhmuH9V+1Q7nmO2RAuRzqZbPwhUa6aVaVI6BnVp uLYomR5OGec2lrXbMKdCSZ/zEeAmOF+PMnQ9KtRBoaRxFu44fEOZ2pnr/GJ67heENDsuyoA qcNsWQGgzgc3HkT2/8/YgNxwGfIeVo9Bf+Dae+hP/duS5+HdM9zPGvm/PhGlJ2WVXplmhwH 6xDCTqPb3JjYZtu3oITww== UI-OutboundReport: notjunk:1;M01:P0:U5vGscs+8hU=;qzQRDMtADq6P8vKu9KWOuiLT5vu CHkeHRV1rWpGe7QSpUnnThM70O7C+4sEQuEY5tQD/ctHJU1iJtwbuoFcmXPWCI8Nh+ggeLUok KfO8rQaDVZs1BHW3OnsbhINyOILQwliGZKztuhWwjhb56h0jXwgpyYFmYxQU6zeoqlYYPnV5E UxDnA6qnjZr53Z1qbM2UiMSV+8JDi8mYNdgfb7skcV9xz5O0op5NEZ5tqFUGWnS4ojwNWcWOQ OZuaeJwpz1E9udxc47U3KZuGAjRvwUF+36O0Pipd6pvNVRvXCPP79rKbWMdBBK4pdeCqefMJ6 WhSEauPO5B44AacelH/cGz4BPfXiRMi/lIMq6y7VNLO7xRWOgpuei6/DaBpWNohKDHRXq9uI5 E7UvB4cBoUte1sJ6VXEWhRc0D/DcbR5khaQ0/eUtjnYMeQ4PMqrOAZBfl5MFh8MC5DTMxtK/Z K4AzY5U+cB2f9bQkc7SsjsGEyP4dzaXENJh/gxblwkMg3bAG/7u86yO39VfAixHfb+tDi7T92 oG6aJxxhIBLVNPtoXs8Rylpo5cDzy3XSyBvXbKtV0ereOMz258okeqxnJXjgiEgmEtX1njzIp mH5updNRzPAu5p7yRlo2OXdWaDNNJ63h1FNJR6cwLl8zZY8dt8zCHTlwkI/axS6yS7t6tF5NO jVtnh9RDbiqh/iUDG61hRZ7zizOoe3MWFY+co+u0ExxUxLsD9o2QLzI+85MxSc7QWlG2hP8RZ mdRh47bDU7Rth3mwfR+kDpuxG9t0y7pYfanHvstsyqt+DP6jtgzd9a1Ft2ze+7TcO1v7mr4oD stcsIVH5yFgZQ6/qckf4e4xlzVDbVARzGWiZoenQOlTLW9FEcPDkI8DgTBYQ73lEsUzG48KX7 envRAxmLJbonSMOZLj1LRQRbO0Srcmdl/epKGPdWBca6e2D0+Rkzmym0ZtAvzwfy1UOOcDYI+ pJhKBHjAIOcxJF8/qhfW4EHSGw8= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The convenience function run_command_v_opt_cd_env_tr2() has no external callers left. Inline it and remove it from the API. Signed-off-by: René Scharfe --- run-command.c | 10 ---------- run-command.h | 10 +--------- 2 files changed, 1 insertion(+), 19 deletions(-) -- 2.38.1 diff --git a/run-command.c b/run-command.c index 32fa4b0ed6..923bad37fe 100644 --- a/run-command.c +++ b/run-command.c @@ -1005,12 +1005,6 @@ int run_command(struct child_process *cmd) } int run_command_v_opt(const char **argv, int opt) -{ - return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, NULL); -} - -int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, - const char *const *env, const char *tr2_class) { struct child_process cmd = CHILD_PROCESS_INIT; strvec_pushv(&cmd.args, argv); @@ -1022,10 +1016,6 @@ int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, cmd.clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0; cmd.wait_after_clean = opt & RUN_WAIT_AFTER_CLEAN ? 1 : 0; cmd.close_object_store = opt & RUN_CLOSE_OBJECT_STORE ? 1 : 0; - cmd.dir = dir; - if (env) - strvec_pushv(&cmd.env, (const char **)env); - cmd.trace2_child_class = tr2_class; return run_command(&cmd); } diff --git a/run-command.h b/run-command.h index 482da7f60c..04bd07dc7a 100644 --- a/run-command.h +++ b/run-command.h @@ -233,23 +233,15 @@ int run_auto_maintenance(int quiet); #define RUN_CLOSE_OBJECT_STORE (1<<7) /** - * Convenience functions that encapsulate a sequence of + * Convenience function that encapsulate a sequence of * start_command() followed by finish_command(). The argument argv * specifies the program and its arguments. The argument opt is zero * or more of the flags `RUN_COMMAND_NO_STDIN`, `RUN_GIT_CMD`, * `RUN_COMMAND_STDOUT_TO_STDERR`, or `RUN_SILENT_EXEC_FAILURE` * that correspond to the members .no_stdin, .git_cmd, * .stdout_to_stderr, .silent_exec_failure of `struct child_process`. - * The argument dir corresponds the member .dir. The argument env - * corresponds to the member .env. */ int run_command_v_opt(const char **argv, int opt); -/* - * env (the environment) is to be formatted like environ: "VAR=VALUE". - * To unset an environment variable use just "VAR". - */ -int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, - const char *const *env, const char *tr2_class); /** * Execute the given command, sending "in" to its stdin, and capturing its From patchwork Thu Oct 27 16:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 13022375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1D28ECAAA1 for ; Thu, 27 Oct 2022 16:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235203AbiJ0Qlh (ORCPT ); Thu, 27 Oct 2022 12:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234879AbiJ0Qlf (ORCPT ); Thu, 27 Oct 2022 12:41:35 -0400 Received: from mout.web.de (mout.web.de [212.227.15.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83701F6C1B for ; Thu, 27 Oct 2022 09:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1666888882; bh=3p6Yx3rurCByS9GZTAVb9s7PcLA6+URayXQZldJmNa4=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=oaG84KizOfLcyyT8qxgOBg6dCp41JKSZqtCitaFMT6dnAmfo9/HB3Az80BfcgODyl gbO+rzvNjtq+QyD72lfljno5PQpHp+SIKTYkbzRB7i2qSqrFWbCIq7HCfElxcFvyYe NVYm3TEB4SQ8GZf8G8R1JwGf+0pBHnsXdccz7jgMjGNYBEOBymGjCQQZnEqEoyCwMo Y1L/Ec3kOLzREcQBVCeUEzAZ9oSulqk7+5a+8Eqd2xpCPVwPkSrkn0F6YiVgbws814 dybwjUBkzHzp83U0ap2VoL+gqmZA1ae31TbNITlvoJI/w5bVEVFWPpVGQBAu3hnowb KsD+W622MZzQw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.29] ([79.203.23.191]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M9ZZo-1okm1O288K-005cwc; Thu, 27 Oct 2022 18:41:22 +0200 Message-ID: <72e04965-56ec-73cb-4554-9e3bc8f10cb5@web.de> Date: Thu, 27 Oct 2022 18:41:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: [PATCH 8/8] replace and remove run_command_v_opt() Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: Git List Cc: Junio C Hamano , Taylor Blau , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= References: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> In-Reply-To: <7407e074-4bd8-b351-7fa4-baf59b41880c@web.de> X-Provags-ID: V03:K1:xB62xHXceQBi21DIBn5UqWp+LU6YGT+qRkesalC9o5gNmV0mQPS 052lKpXELlSTZzNsNBqpMK1MW0iLA2fbsVIyW9RNuKMBIhvAMjQv+3nlGBIAGmhY6bwmv52 hjXJJ7fnJRdQvgpv/Xjgl6jsbQqO9stIQCNVOlbdmxzbKyfE6BMH+SoqK9lIotRt89owrgL Bchkoy4kr8PxiwGmQPSUQ== UI-OutboundReport: notjunk:1;M01:P0:BEpxSlgS4gI=;KP+bu0lLalvZV3UGaPKgyoaiCT5 hjv1652UofVQga+ULJRUwSpsfXERJdwtrYW8i/ljZXy408OVY4TxymYronR2uMErQ8IUHMKal Ob5bvjpv9hOaFLOZv7Df6nq3z/HZHYlNS/vyNYao6jDftT1SDZNNF4aBq/4nJl1H6U8d2Ui7L Pq1dJO7JsJOYorwH3AaUteQgJrG6eN+5oaQnIPdMgesp/HytVu6zJO0a0CiZO6OPGabRUR9UQ 8fR50EbpebIM2q72RuGdZXrvCaD0TATfmjzvbhrgHbaMuebeQvwVnPz86DPzkPdZt9iKa5Nzd 736NrYpfgHLjBADLKsaJanQ6vcv7LtuplVf8WcJUbDf3/XTkNvYlkP8dMuZ6gq35WOgaf/nid B3Ae0El99ujeKUdCK0fGpBGey7YpzhMJ9m+OyWmfyJyvNvpkCTK2Q9jNRZKJ8KpgAz6gaXBPk Hn1jovawiUdjLMLwtW0ExpaRbl3MoD57PhOSqNYTfsPf7vgvJNsQTT/8hpy5vzLC+Dyj4AVYk iCvzvuQvN3p7WExGInCYg5swAbI0KL1Qg5r8phrjj8jK+l7Yxgwg7VO+uDriA0t8VMaj8TAl0 F/eXuv+USZl9WIHS35V3/0Ioj91I1ftrq6oBzN48j0staOcHUT3I5lnKLvzYqiXRha9jDx/5K bdAjpzPYQ6VXOW/G32CUTQWwjiiHCWuiWtNZCXJ36ZwZCYcLUkcNtAkqcGX8cCQfa+uehlmQZ RrH8iHpGANZ2ArwWhBBSVsF23gs37Lu545PZJcU5/j9636uELRFnhFPDPSKvQBc7q3NhsK/Lx bHubPOAjrdbb5mh09cWudK9u/J+QoB9oMzWqLJ22QKCxN8RKtDiOauR5IgwPvHZ6V8Ec4ELI6 kM/sOn+ccApNFdWkOaM/vx3RNr6XugZf24ksAsQrKHlZTYsKkIlMuPGInxDjrvuS/u1XXQ1u/ RszjtAJzVL5az6IaSky1PWNuJ3k= Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace the remaining calls of run_command_v_opt() with run_command() calls and explict struct child_process variables. This is more verbose, but not by much overall. The code becomes more flexible, e.g. it's easy to extend to conditionally add a new argument. Then remove the now unused function and its own flag names, simplifying the run-command API. Suggested-by: Jeff King Signed-off-by: René Scharfe Signed-off-by: René Scharfe --- builtin/bisect--helper.c | 15 ++++++++++----- builtin/clone.c | 8 ++++++-- builtin/difftool.c | 7 +++++-- builtin/fetch.c | 9 ++++++--- builtin/gc.c | 41 +++++++++++++++++++++++++++++++--------- builtin/merge-index.c | 4 +++- run-command.c | 15 --------------- run-command.h | 22 +-------------------- shell.c | 17 ++++++++++++----- t/helper/test-trace2.c | 4 +++- 10 files changed, 78 insertions(+), 64 deletions(-) -- 2.38.1 diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 5c63ba6994..1d2ce8a0e1 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -764,10 +764,12 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a strbuf_read_file(&start_head, git_path_bisect_start(), 0); strbuf_trim(&start_head); if (!no_checkout) { - const char *argv[] = { "checkout", start_head.buf, - "--", NULL }; + struct child_process cmd = CHILD_PROCESS_INIT; - if (run_command_v_opt(argv, RUN_GIT_CMD)) { + cmd.git_cmd = 1; + strvec_pushl(&cmd.args, "checkout", start_head.buf, + "--", NULL); + if (run_command(&cmd)) { res = error(_("checking out '%s' failed." " Try 'git bisect start " "'."), @@ -1141,9 +1143,12 @@ static int get_first_good(const char *refname UNUSED, static int do_bisect_run(const char *command) { - const char *argv[] = { command, NULL }; + struct child_process cmd = CHILD_PROCESS_INIT; + printf(_("running %s\n"), command); - return run_command_v_opt(argv, RUN_USING_SHELL); + cmd.use_shell = 1; + strvec_push(&cmd.args, command); + return run_command(&cmd); } static int verify_good(const struct bisect_terms *terms, const char *command) diff --git a/builtin/clone.c b/builtin/clone.c index 56e7775dae..0e4348686b 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -865,11 +865,15 @@ static void write_refspec_config(const char *src_ref_prefix, static void dissociate_from_references(void) { - static const char* argv[] = { "repack", "-a", "-d", NULL }; char *alternates = git_pathdup("objects/info/alternates"); if (!access(alternates, F_OK)) { - if (run_command_v_opt(argv, RUN_GIT_CMD|RUN_COMMAND_NO_STDIN)) + struct child_process cmd = CHILD_PROCESS_INIT; + + cmd.git_cmd = 1; + cmd.no_stdin = 1; + strvec_pushl(&cmd.args, "repack", "-a", "-d", NULL); + if (run_command(&cmd)) die(_("cannot repack to clean up")); if (unlink(alternates) && errno != ENOENT) die_errno(_("cannot unlink temporary alternates file")); diff --git a/builtin/difftool.c b/builtin/difftool.c index 22bcc3444b..d7f08c8a7f 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -44,8 +44,11 @@ static int difftool_config(const char *var, const char *value, void *cb) static int print_tool_help(void) { - const char *argv[] = { "mergetool", "--tool-help=diff", NULL }; - return run_command_v_opt(argv, RUN_GIT_CMD); + struct child_process cmd = CHILD_PROCESS_INIT; + + cmd.git_cmd = 1; + strvec_pushl(&cmd.args, "mergetool", "--tool-help=diff", NULL); + return run_command(&cmd); } static int parse_index_info(char *p, int *mode1, int *mode2, diff --git a/builtin/fetch.c b/builtin/fetch.c index a0fca93bb6..dd060dd65a 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1965,14 +1965,17 @@ static int fetch_multiple(struct string_list *list, int max_children) } else for (i = 0; i < list->nr; i++) { const char *name = list->items[i].string; - strvec_push(&argv, name); + struct child_process cmd = CHILD_PROCESS_INIT; + + strvec_pushv(&cmd.args, argv.v); + strvec_push(&cmd.args, name); if (verbosity >= 0) printf(_("Fetching %s\n"), name); - if (run_command_v_opt(argv.v, RUN_GIT_CMD)) { + cmd.git_cmd = 1; + if (run_command(&cmd)) { error(_("could not fetch %s"), name); result = 1; } - strvec_pop(&argv); } strvec_clear(&argv); diff --git a/builtin/gc.c b/builtin/gc.c index 87ad0077d8..962bab61f9 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -167,9 +167,11 @@ static void gc_config(void) struct maintenance_run_opts; static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts) { - const char *argv[] = { "pack-refs", "--all", "--prune", NULL }; + struct child_process cmd = CHILD_PROCESS_INIT; - return run_command_v_opt(argv, RUN_GIT_CMD); + cmd.git_cmd = 1; + strvec_pushl(&cmd.args, "pack-refs", "--all", "--prune", NULL); + return run_command(&cmd); } static int too_many_loose_objects(void) @@ -535,8 +537,14 @@ static void gc_before_repack(void) if (pack_refs && maintenance_task_pack_refs(NULL)) die(FAILED_RUN, "pack-refs"); - if (prune_reflogs && run_command_v_opt(reflog.v, RUN_GIT_CMD)) - die(FAILED_RUN, reflog.v[0]); + if (prune_reflogs) { + struct child_process cmd = CHILD_PROCESS_INIT; + + cmd.git_cmd = 1; + strvec_pushv(&cmd.args, reflog.v); + if (run_command(&cmd)) + die(FAILED_RUN, reflog.v[0]); + } } int cmd_gc(int argc, const char **argv, const char *prefix) @@ -550,6 +558,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix) int daemonized = 0; int keep_largest_pack = -1; timestamp_t dummy; + struct child_process rerere_cmd = CHILD_PROCESS_INIT; struct option builtin_gc_options[] = { OPT__QUIET(&quiet, N_("suppress progress reporting")), @@ -671,11 +680,17 @@ int cmd_gc(int argc, const char **argv, const char *prefix) gc_before_repack(); if (!repository_format_precious_objects) { - if (run_command_v_opt(repack.v, - RUN_GIT_CMD | RUN_CLOSE_OBJECT_STORE)) + struct child_process repack_cmd = CHILD_PROCESS_INIT; + + repack_cmd.git_cmd = 1; + repack_cmd.close_object_store = 1; + strvec_pushv(&repack_cmd.args, repack.v); + if (run_command(&repack_cmd)) die(FAILED_RUN, repack.v[0]); if (prune_expire) { + struct child_process prune_cmd = CHILD_PROCESS_INIT; + /* run `git prune` even if using cruft packs */ strvec_push(&prune, prune_expire); if (quiet) @@ -683,18 +698,26 @@ int cmd_gc(int argc, const char **argv, const char *prefix) if (has_promisor_remote()) strvec_push(&prune, "--exclude-promisor-objects"); - if (run_command_v_opt(prune.v, RUN_GIT_CMD)) + prune_cmd.git_cmd = 1; + strvec_pushv(&prune_cmd.args, prune.v); + if (run_command(&prune_cmd)) die(FAILED_RUN, prune.v[0]); } } if (prune_worktrees_expire) { + struct child_process prune_worktrees_cmd = CHILD_PROCESS_INIT; + strvec_push(&prune_worktrees, prune_worktrees_expire); - if (run_command_v_opt(prune_worktrees.v, RUN_GIT_CMD)) + prune_worktrees_cmd.git_cmd = 1; + strvec_pushv(&prune_worktrees_cmd.args, prune_worktrees.v); + if (run_command(&prune_worktrees_cmd)) die(FAILED_RUN, prune_worktrees.v[0]); } - if (run_command_v_opt(rerere.v, RUN_GIT_CMD)) + rerere_cmd.git_cmd = 1; + strvec_pushv(&rerere_cmd.args, rerere.v); + if (run_command(&rerere_cmd)) die(FAILED_RUN, rerere.v[0]); report_garbage = report_pack_garbage; diff --git a/builtin/merge-index.c b/builtin/merge-index.c index c0383fe9df..012f52bd00 100644 --- a/builtin/merge-index.c +++ b/builtin/merge-index.c @@ -12,6 +12,7 @@ static int merge_entry(int pos, const char *path) const char *arguments[] = { pgm, "", "", "", path, "", "", "", NULL }; char hexbuf[4][GIT_MAX_HEXSZ + 1]; char ownbuf[4][60]; + struct child_process cmd = CHILD_PROCESS_INIT; if (pos >= active_nr) die("git merge-index: %s not in the cache", path); @@ -31,7 +32,8 @@ static int merge_entry(int pos, const char *path) if (!found) die("git merge-index: %s not in the cache", path); - if (run_command_v_opt(arguments, 0)) { + strvec_pushv(&cmd.args, arguments); + if (run_command(&cmd)) { if (one_shot) err++; else { diff --git a/run-command.c b/run-command.c index 923bad37fe..23e100dffc 100644 --- a/run-command.c +++ b/run-command.c @@ -1004,21 +1004,6 @@ int run_command(struct child_process *cmd) return finish_command(cmd); } -int run_command_v_opt(const char **argv, int opt) -{ - struct child_process cmd = CHILD_PROCESS_INIT; - strvec_pushv(&cmd.args, argv); - cmd.no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0; - cmd.git_cmd = opt & RUN_GIT_CMD ? 1 : 0; - cmd.stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0; - cmd.silent_exec_failure = opt & RUN_SILENT_EXEC_FAILURE ? 1 : 0; - cmd.use_shell = opt & RUN_USING_SHELL ? 1 : 0; - cmd.clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0; - cmd.wait_after_clean = opt & RUN_WAIT_AFTER_CLEAN ? 1 : 0; - cmd.close_object_store = opt & RUN_CLOSE_OBJECT_STORE ? 1 : 0; - return run_command(&cmd); -} - #ifndef NO_PTHREADS static pthread_t main_thread; static int main_thread_set; diff --git a/run-command.h b/run-command.h index 04bd07dc7a..fe2717ad11 100644 --- a/run-command.h +++ b/run-command.h @@ -151,7 +151,7 @@ struct child_process { /** * The functions: child_process_init, start_command, finish_command, - * run_command, run_command_v_opt, child_process_clear do the following: + * run_command, child_process_clear do the following: * * - If a system call failed, errno is set and -1 is returned. A diagnostic * is printed. @@ -223,26 +223,6 @@ int run_command(struct child_process *); */ int run_auto_maintenance(int quiet); -#define RUN_COMMAND_NO_STDIN (1<<0) -#define RUN_GIT_CMD (1<<1) -#define RUN_COMMAND_STDOUT_TO_STDERR (1<<2) -#define RUN_SILENT_EXEC_FAILURE (1<<3) -#define RUN_USING_SHELL (1<<4) -#define RUN_CLEAN_ON_EXIT (1<<5) -#define RUN_WAIT_AFTER_CLEAN (1<<6) -#define RUN_CLOSE_OBJECT_STORE (1<<7) - -/** - * Convenience function that encapsulate a sequence of - * start_command() followed by finish_command(). The argument argv - * specifies the program and its arguments. The argument opt is zero - * or more of the flags `RUN_COMMAND_NO_STDIN`, `RUN_GIT_CMD`, - * `RUN_COMMAND_STDOUT_TO_STDERR`, or `RUN_SILENT_EXEC_FAILURE` - * that correspond to the members .no_stdin, .git_cmd, - * .stdout_to_stderr, .silent_exec_failure of `struct child_process`. - */ -int run_command_v_opt(const char **argv, int opt); - /** * Execute the given command, sending "in" to its stdin, and capturing its * stdout and stderr in the "out" and "err" strbufs. Any of the three may diff --git a/shell.c b/shell.c index 7ff4109db7..af0d7c734f 100644 --- a/shell.c +++ b/shell.c @@ -52,21 +52,24 @@ static void cd_to_homedir(void) static void run_shell(void) { int done = 0; - static const char *help_argv[] = { HELP_COMMAND, NULL }; + struct child_process help_cmd = CHILD_PROCESS_INIT; if (!access(NOLOGIN_COMMAND, F_OK)) { /* Interactive login disabled. */ - const char *argv[] = { NOLOGIN_COMMAND, NULL }; + struct child_process nologin_cmd = CHILD_PROCESS_INIT; int status; - status = run_command_v_opt(argv, 0); + strvec_push(&nologin_cmd.args, NOLOGIN_COMMAND); + status = run_command(&nologin_cmd); if (status < 0) exit(127); exit(status); } /* Print help if enabled */ - run_command_v_opt(help_argv, RUN_SILENT_EXEC_FAILURE); + help_cmd.silent_exec_failure = 1; + strvec_push(&help_cmd.args, HELP_COMMAND); + run_command(&help_cmd); do { const char *prog; @@ -125,9 +128,13 @@ static void run_shell(void) !strcmp(prog, "exit") || !strcmp(prog, "bye")) { done = 1; } else if (is_valid_cmd_name(prog)) { + struct child_process cmd = CHILD_PROCESS_INIT; + full_cmd = make_cmd(prog); argv[0] = full_cmd; - code = run_command_v_opt(argv, RUN_SILENT_EXEC_FAILURE); + cmd.silent_exec_failure = 1; + strvec_pushv(&cmd.args, argv); + code = run_command(&cmd); if (code == -1 && errno == ENOENT) { fprintf(stderr, "unrecognized command '%s'\n", prog); } diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c index a714130ece..94fd8ccf51 100644 --- a/t/helper/test-trace2.c +++ b/t/helper/test-trace2.c @@ -132,6 +132,7 @@ static int ut_003error(int argc, const char **argv) */ static int ut_004child(int argc, const char **argv) { + struct child_process cmd = CHILD_PROCESS_INIT; int result; /* @@ -141,7 +142,8 @@ static int ut_004child(int argc, const char **argv) if (!argc) return 0; - result = run_command_v_opt(argv, 0); + strvec_pushv(&cmd.args, argv); + result = run_command(&cmd); exit(result); }