Re: [PATCH] advice: refactor advise API
From: Junio C Hamano <hidden>
Date: 2020-02-11 06:08:22
Heba Waly [off-list ref] writes:
On Tue, Feb 11, 2020 at 11:46 AM Junio C Hamano [off-list ref] wrote:quoted
As I outlined in [1], I think the over-simplified "advise_ng(<advise.key>, _(<message>), ...)" would be too limited to replace the current users, without a pair of helper functions, one to just check for the guarding advise.key, and the other to unconditionally show the message (i.e. the latter is what the current advise() is).I agree with adding the first helper, specially after Peff's comments, but I don't see why we would keep the current advise() which unconditionally shows the message...
Look again at the message you referenced in your message that
started this round, and read its comment:
if (advise_ng_enabled("frotz")) {
char *result = expensive_computation(...);
/*
* advise_ng("frotz", _("message %s about frotz", result));
* is fine as well, but slightly less efficient as
* it would involve another call to *_enabled(), so use
* the unconditional form of the call
*/
advise_ng_raw(_("message %s about frotz", result));
free(result);
}