All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: ab/run-command (was: What's cooking in git.git (Dec 2021, #04; Wed, 15))
Date: Thu, 16 Dec 2021 12:51:55 +0100	[thread overview]
Message-ID: <211216.868rwkbv1b.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <xmqq8rwlz3cq.fsf@gitster.g>


On Wed, Dec 15 2021, Junio C Hamano wrote:

> [Graduated to 'master']
> [...]
> * ab/run-command (2021-11-25) 9 commits
>   (merged to 'next' on 2021-12-07 at 5c0bedf853)
>  + run-command API: remove "env" member, always use "env_array"
>  + difftool: use "env_array" to simplify memory management
>  + run-command API: remove "argv" member, always use "args"
>  + run-command API users: use strvec_push(), not argv construction
>  + run-command API users: use strvec_pushl(), not argv construction
>  + run-command tests: use strvec_pushv(), not argv assignment
>  + run-command API users: use strvec_pushv(), not argv assignment
>  + upload-archive: use regular "struct child_process" pattern
>  + worktree: stop being overly intimate with run_command() internals
>
>  API clean-up.
>  cf. <211130.86k0gpcpy2.gmgdl@evledraar.gmail.com>
>  cf. <CAPig+cSvFgJTiq8pXrWy_7ukQwE1y9ZGwMgKmyjWuQHdNGxiDQ@mail.gmail.com>
>  source: <cover-v3-0.9-00000000000-20211125T224833Z-avarab@gmail.com>

Thanks! FWIW the tip commit mentioned that renaming "env_array" to "env"
probably wasn't worth it, but having tried it just now I think it's
probably a worthwhile follow-up at some point. The diff is just:
	
	diff --git a/run-command.h b/run-command.h
	index 2be5f5d6422..c5d44cc9a5c 100644
	--- a/run-command.h
	+++ b/run-command.h
	@@ -73,7 +73,7 @@ struct child_process {
	 	 * The memory in .env_array will be cleaned up automatically during
	 	 * `finish_command` (or during `start_command` when it is unsuccessful).
	 	 */
	-	struct strvec env_array;
	+	struct strvec env;
	 	pid_t pid;
	 
	 	int trace2_child_id;
	@@ -147,7 +147,7 @@ struct child_process {
	 
	 #define CHILD_PROCESS_INIT { \
	 	.args = STRVEC_INIT, \
	-	.env_array = STRVEC_INIT, \
	+	.env = STRVEC_INIT, \
	 }
	 
	 /**

Followed by a rather large mechanical change, but that change can almost
entirely be done with this cocci rule:
    
    @@
    struct child_process E;
    @@
    - E.env_array
    + E.env
    
    @@
    struct child_process *E;
    @@
    - E->env_array
    + E->env

The "almost" being that we'll also need this on top:
    
     builtin/submodule--helper.c |  2 +-
     run-command.c               |  6 +++---
     run-command.h               | 10 +++++-----
     sequencer.c                 |  6 +++---
     submodule.h                 |  4 ++--
     5 files changed, 14 insertions(+), 14 deletions(-)

Which changes comments and function/variable names that refer to
"env_array" to refer to "env".

I won't submit it now because we've got some "env_array" in
master..seen, but there'll probably be a time when there'll be none
which might make it trivial.

Or maybe you're not interested in either case, which is also fine. It's
really not needed for anything other than to resolve the minor oddity
that we have two "struct strvec"'s, "args" and "env_array". It's just a
bit odd to have one with "_array" in the name, which is only because the
now-removed "env" was taken at the time.

  reply	other threads:[~2021-12-16 12:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16  2:32 What's cooking in git.git (Dec 2021, #04; Wed, 15) Junio C Hamano
2021-12-16 11:51 ` Ævar Arnfjörð Bjarmason [this message]
2021-12-16 15:31   ` ab/run-command (was: What's cooking in git.git (Dec 2021, #04; Wed, 15)) Jeff King
2021-12-16 15:38     ` Ævar Arnfjörð Bjarmason
2021-12-16 19:11       ` ab/run-command Junio C Hamano
2022-04-06 10:42     ` [PATCH 0/3] run-command.h: rename "env_array" to "env" Ævar Arnfjörð Bjarmason
2022-04-06 10:42       ` [PATCH 1/3] cocci: add a rename of "struct child_process"'s " Ævar Arnfjörð Bjarmason
2022-04-06 10:42       ` [PATCH 2/3] run-command API: rename " Ævar Arnfjörð Bjarmason
2022-04-06 10:42       ` [PATCH 3/3] run-command API users: use "env" not "env_array" in comments & names Ævar Arnfjörð Bjarmason
2022-04-07 12:09       ` [PATCH 0/3] run-command.h: rename "env_array" to "env" Johannes Schindelin
2022-04-07 16:48         ` Junio C Hamano
2022-04-07 17:52           ` Junio C Hamano
2022-05-20  7:24       ` [PATCH v2 0/4] " Ævar Arnfjörð Bjarmason
2022-05-20  7:24         ` [PATCH v2 1/4] cocci: add a rename of "struct child_process"'s " Ævar Arnfjörð Bjarmason
2022-05-20  7:24         ` [PATCH v2 2/4] run-command API: rename " Ævar Arnfjörð Bjarmason
2022-05-20  7:24         ` [PATCH v2 3/4] cocci: remove env_array -> env migration Ævar Arnfjörð Bjarmason
2022-05-20  7:24         ` [PATCH v2 4/4] run-command API users: use "env" not "env_array" in comments & names Ævar Arnfjörð Bjarmason
2022-05-20 16:27         ` [PATCH v2 0/4] run-command.h: rename "env_array" to "env" Junio C Hamano
2022-05-21 11:09           ` Ævar Arnfjörð Bjarmason
2022-06-02  9:09         ` [PATCH v3 0/2] " Ævar Arnfjörð Bjarmason
2022-06-02  9:09           ` [PATCH v3 1/2] run-command API: " Ævar Arnfjörð Bjarmason
2022-06-03  0:37             ` Junio C Hamano
2022-06-02  9:09           ` [PATCH v3 2/2] run-command API users: use "env" not "env_array" in comments & names Ævar Arnfjörð Bjarmason
2021-12-16 23:46 ` ab/make-dependency (was: What's cooking in git.git (Dec 2021, #04; Wed, 15)) Ævar Arnfjörð Bjarmason
2021-12-21  1:34 ` What's cooking in git.git (Dec 2021, #04; Wed, 15) Aleen 徐沛文
2021-12-21  7:30   ` Christian Couder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=211216.868rwkbv1b.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.