summaryrefslogtreecommitdiff
path: root/advice.c
diff options
context:
space:
mode:
authorHeba Waly <heba.waly@gmail.com>2020-03-02 20:01:57 +0000
committerJunio C Hamano <gitster@pobox.com>2020-03-02 12:37:21 -0800
commit06ac2b3b6e30e65f4f9bc63ca78a1e33025f2e4c (patch)
tree68bb19e0bbc281c8fb821d42d39f0128b452bdab /advice.c
parentd0654dc308b0ba76dd8ed7bbb33c8d8f7aacd783 (diff)
downloadgit-06ac2b3b6e30e65f4f9bc63ca78a1e33025f2e4c.tar.gz
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>
Diffstat (limited to 'advice.c')
-rw-r--r--advice.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/advice.c b/advice.c
index 249c60dcf3..fd836332da 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;