git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: "Git Mailing List" <git@vger.kernel.org>,
	"Jeff King" <peff@peff.net>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Johannes Sixt" <j6t@kdbg.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Phillip Wood" <phillip.wood123@gmail.com>,
	"Jonathan Nieder" <jrnieder@gmail.com>
Subject: Re: [PATCH v2 3/7] rebase: add support for multiple hooks
Date: Tue, 14 May 2019 19:56:49 +0700	[thread overview]
Message-ID: <CACsJy8CnCoMK7ahjRotKfiC2ic-U0hdhKuQAeF-TtVt8N+bU2Q@mail.gmail.com> (raw)
In-Reply-To: <20190514002332.121089-4-sandals@crustytoothpaste.net>

On Tue, May 14, 2019 at 7:24 AM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
> diff --git a/builtin/am.c b/builtin/am.c
> index 912d9821b1..340eacbd44 100644
> --- a/builtin/am.c
> +++ b/builtin/am.c
> @@ -441,24 +441,8 @@ static int run_applypatch_msg_hook(struct am_state *state)
>   */
>  static int run_post_rewrite_hook(const struct am_state *state)
>  {
> -       struct child_process cp = CHILD_PROCESS_INIT;
> -       const char *hook = find_hook("post-rewrite");
> -       int ret;
> -
> -       if (!hook)
> -               return 0;
> -
> -       argv_array_push(&cp.args, hook);
> -       argv_array_push(&cp.args, "rebase");
> -
> -       cp.in = xopen(am_path(state, "rewritten"), O_RDONLY);
> -       cp.stdout_to_stderr = 1;
> -       cp.trace2_hook_name = "post-rewrite";
> -
> -       ret = run_command(&cp);
> -
> -       close(cp.in);

In the old code, we close cp.in...

> +int post_rewrite_rebase_hook(const char *name, const char *path, void *input)
> +{
> +       struct child_process child = CHILD_PROCESS_INIT;
> +
> +       child.in = open(input, O_RDONLY);
> +       child.stdout_to_stderr = 1;
> +       child.trace2_hook_name = "post-rewrite";

maybe use "name" and avoid hard coding "post-rewrite".

> +       argv_array_push(&child.args, path);
> +       argv_array_push(&child.args, "rebase");
> +       return run_command(&child);

... but in the new one we don't. Smells fd leaking to me.
-- 
Duy

  reply	other threads:[~2019-05-14 12:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14  0:23 [PATCH v2 0/7] Multiple hook support brian m. carlson
2019-05-14  0:23 ` [PATCH v2 1/7] run-command: add preliminary support for multiple hooks brian m. carlson
2019-05-14 12:46   ` Duy Nguyen
2019-05-15 22:27     ` brian m. carlson
2019-05-29  2:18       ` brian m. carlson
2019-05-14 15:12   ` Johannes Schindelin
2019-05-15 22:44     ` brian m. carlson
2019-05-16 19:11       ` Johannes Sixt
2019-05-17 20:31         ` Johannes Schindelin
2019-05-14  0:23 ` [PATCH v2 2/7] builtin/receive-pack: add " brian m. carlson
2019-05-14  0:23 ` [PATCH v2 3/7] rebase: " brian m. carlson
2019-05-14 12:56   ` Duy Nguyen [this message]
2019-05-14 17:58     ` Johannes Sixt
2019-05-15 22:55     ` brian m. carlson
2019-05-16 10:29       ` Duy Nguyen
2019-05-14  0:23 ` [PATCH v2 3/7] sequencer: " brian m. carlson
2019-05-14  0:23 ` [PATCH v2 4/7] builtin/worktree: add support for multiple post-checkout hooks brian m. carlson
2019-05-14  0:23 ` [PATCH v2 5/7] transport: add support for multiple pre-push hooks brian m. carlson
2019-05-14  0:23 ` [PATCH v2 6/7] config: allow configuration of multiple hook error behavior brian m. carlson
2019-05-14 13:20   ` Duy Nguyen
2019-05-15 23:10     ` brian m. carlson
2019-05-16  5:08       ` Jeff King
2019-05-16  5:02   ` Jeff King
2019-05-16 17:19     ` brian m. carlson
2019-05-16 21:52       ` Jeff King
2019-05-14  0:23 ` [PATCH v2 7/7] docs: document multiple hooks brian m. carlson
2019-05-14 13:38   ` Duy Nguyen
2019-05-14  0:51 ` [PATCH v2 0/7] Multiple hook support Jonathan Nieder
2019-05-14  1:59   ` brian m. carlson
2019-05-14  2:26     ` Jonathan Nieder
2019-05-16  0:42       ` brian m. carlson
2019-05-16  0:51         ` Jonathan Nieder
2019-05-16  4:51     ` Jeff King
2019-05-14 13:30 ` Duy Nguyen

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CACsJy8CnCoMK7ahjRotKfiC2ic-U0hdhKuQAeF-TtVt8N+bU2Q@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=phillip.wood123@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).