From: Junio C Hamano Date: Wed, 09 Sep 2009 19:06:21 GMT Subject: Re: [PATCH 1/2] push: make non-fast-forward help message configurable Message-ID: <7vr5ugszte.fsf@alter.siamese.dyndns.org> In-Reply-To: <20090909113858.GA31051@coredump.intra.peff.net> Jeff King writes: > diff --git a/advice.c b/advice.c > new file mode 100644 > index 0000000..b5216a2 > --- /dev/null > +++ b/advice.c > @@ -0,0 +1,25 @@ > +#include "cache.h" > + > +int advice_push_nonfastforward = 1; > + > +static struct { > + const char *name; > + int *preference; > +} advice_config[] = { > + { "pushnonfastforward", &advice_push_nonfastforward }, > +}; Can we have the value inside this struct, instead of having a pointer to another variable, and get rid of that variable altogether? > diff --git a/builtin-push.c b/builtin-push.c > index 787011f..6eda372 100644 > --- a/builtin-push.c > +++ b/builtin-push.c > @@ -157,7 +157,7 @@ static int do_push(const char *repo, int flags) > continue; > > error("failed to push some refs to '%s'", url[i]); > - if (nonfastforward) { > + if (nonfastforward && advice_push_nonfastforward) { If we did so, this part needs to become if (nonfastforward && check_advice("pushnonfastforward")) { which would be less efficient, but by definition advices are on the slow path, right? And check_advice() implementation can find programming errors by barfing when the given string token does not exist in the table.