Re: [PATCH 3/3] sequencer: use read_author_script()
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Sep 12, 2018, 12:14 UTC
- Message-ID
- <CAPig+cRvUr26GZyW6ecYhpwABueBqaEfZH1+JjLaqZo8+RTD6Q@mail.gmail.com>
- In-Reply-To
- <20180912101029.28052-4-phillip.wood@talktalk.net>
On Wed, Sep 12, 2018 at 6:11 AM Phillip Wood <phillip.wood@talktalk.net> wrote:
Show 24 quoted lines
> Use the new function to read the author script, updating
> read_env_script() and read_author_ident(). This means we now have a
> single code path that reads the author script and uses sq_dequote() to
> dequote it. This fixes potential problems with user edited scripts
> as read_env_script() which did not track quotes properly.
> [...]
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
> diff --git a/sequencer.c b/sequencer.c
> @@ -723,54 +723,35 @@ int read_author_script(const char *path, char **name, char **email, char **date,
> static int read_env_script(struct argv_array *env)
> {
> + strbuf_addstr(&script, "GIT_AUTHOR_NAME=");
> + strbuf_addstr(&script, name);
> + argv_array_push(env, script.buf);
> + strbuf_reset(&script);
> + strbuf_addstr(&script, "GIT_AUTHOR_EMAIL=");
> + strbuf_addstr(&script, email);
> + argv_array_push(env, script.buf);
> + strbuf_reset(&script);
> + strbuf_addstr(&script, "GIT_AUTHOR_DATE=");
> + strbuf_addstr(&script, date);
> + argv_array_push(env, script.buf);
> + strbuf_release(&script);I haven't read this series closely yet, but this caught my eye while scanning it quickly. The above noisy code can all be collapsed to the simpler:
argv_array_pushf(env, "GIT_AUTHOR_NAME=%s", name);
argv_array_pushf(env, "GIT_AUTHOR_EMAIL =%s", email);
argv_array_pushf(env, "GIT_AUTHOR_DATE =%s", date);