Skip to content

Commit 06ac2b3

Browse files
HebaWalygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Heba Waly <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0654dc commit 06ac2b3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

advice.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,12 @@ static struct {
9696
{ "pushNonFastForward", &advice_push_update_rejected }
9797
};
9898

99-
void advise(const char *advice, ...)
99+
static void vadvise(const char *advice, va_list params)
100100
{
101101
struct strbuf buf = STRBUF_INIT;
102-
va_list params;
103102
const char *cp, *np;
104103

105-
va_start(params, advice);
106104
strbuf_vaddf(&buf, advice, params);
107-
va_end(params);
108105

109106
for (cp = buf.buf; *cp; cp = np) {
110107
np = strchrnul(cp, '\n');
@@ -118,6 +115,14 @@ void advise(const char *advice, ...)
118115
strbuf_release(&buf);
119116
}
120117

118+
void advise(const char *advice, ...)
119+
{
120+
va_list params;
121+
va_start(params, advice);
122+
vadvise(advice, params);
123+
va_end(params);
124+
}
125+
121126
int git_default_advice_config(const char *var, const char *value)
122127
{
123128
const char *k, *slot_name;

0 commit comments

Comments
 (0)