Subject: Re: [PATCH v4 1/3] advice: extract vadvise() from advise()

From: Emily Shaffer <[email-masked]>
Date: Mon, 24 Feb 2020 14:04:15 -0800

On Mon, Feb 24, 2020 at 03:13:16PM +0000, Heba Waly via GitGitGadget wrote:
> From: Heba Waly <[email-masked]>
> 
> In preparation for a new advice method, extract a version of advise()
> that uses an explict 'va_list' parameter. Call it from advise() for a
> functionally equivalent version.
> 
> Signed-off-by: Derrick Stolee <[email-masked]>
> Signed-off-by: Heba Waly <[email-masked]>

This seems very straightforward and now appears to be in the right
commit order.

Reviewed-by: Emily Shaffer <[email-masked]>

> ---
>  advice.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/advice.c b/advice.c
> index 249c60dcf32..fd836332dad 100644
> --- a/advice.c
> +++ b/advice.c
> @@ -96,15 +96,12 @@ static struct {
>  	{ "pushNonFastForward", &advice_push_update_rejected }
>  };
>  
> -void advise(const char *advice, ...)
> +static void vadvise(const char *advice, va_list params)
>  {
>  	struct strbuf buf = STRBUF_INIT;
> -	va_list params;
>  	const char *cp, *np;
>  
> -	va_start(params, advice);
>  	strbuf_vaddf(&buf, advice, params);
> -	va_end(params);
>  
>  	for (cp = buf.buf; *cp; cp = np) {
>  		np = strchrnul(cp, '\n');
> @@ -118,6 +115,14 @@ void advise(const char *advice, ...)
>  	strbuf_release(&buf);
>  }
>  
> +void advise(const char *advice, ...)
> +{
> +	va_list params;
> +	va_start(params, advice);
> +	vadvise(advice, params);
> +	va_end(params);
> +}
> +
>  int git_default_advice_config(const char *var, const char *value)
>  {
>  	const char *k, *slot_name;
> -- 
> gitgitgadget
>