Browse Source

advice: extract vadvise() from advise()

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 <dstolee@microsoft.com>
Signed-off-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Heba Waly 5 years ago committed by Junio C Hamano
parent
commit
06ac2b3b6e
  1. 13
      advice.c

13
advice.c

@ -96,15 +96,12 @@ static struct { @@ -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, ...) @@ -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;

Loading…
Cancel
Save