Re: [PATCH v8 10/37] hook: support passing stdin to hooks
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 12, 2021, 10:22 UTC
- Message-ID
- <xmqqczw48ye2.fsf@gitster.g>
- In-Reply-To
- <20210311021037.3001235-11-emilyshaffer@google.com>
Emily Shaffer <emilyshaffer@google.com> writes:
Show 11 quoted lines
> diff --git a/hook.c b/hook.c
> index 118931f273..f906e8c61c 100644
> --- a/hook.c
> +++ b/hook.c
> @@ -240,6 +240,7 @@ void run_hooks_opt_init(struct run_hooks_opt *o)
> {
> strvec_init(&o->env);
> strvec_init(&o->args);
> + o->path_to_stdin = NULL;
> o->run_hookdir = configured_hookdir_opt();
> }The new member is initialized to NULL, and presumably the user of the API would point an existing string with it. Since there is no free() in opt_clear() introduced by this patch, the member is obviously a pointer to a borrowed piece of memory.
Show 12 quoted lines
> diff --git a/hook.h b/hook.h > index 0df785add5..2314ec5962 100644 > --- a/hook.h > +++ b/hook.h > @@ -52,6 +52,9 @@ struct run_hooks_opt > * to be overridden if the user can override it at the command line. > */ > enum hookdir_opt run_hookdir; > + > + /* Path to file which should be piped to stdin for each hook */ > + const char *path_to_stdin; > };
And we mark the fact that hook subsystem does not own it by making it "const char *". Looks quite consistent. Good.