Re: [PATCHv4] pretty: Initialize notes if %N is used
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 13, 2010, 20:01 UTC
- Message-ID
- <7vzl17t944.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1271157981-9767-1-git-send-email-heipei@hackvalue.de>
Johannes Gilger <heipei@hackvalue.de> writes:
Show 13 quoted lines
> +void userformat_find_requirements(const char *fmt, struct userformat_want *w)
> +{
> + struct strbuf dummy = STRBUF_INIT;
> +
> + memset(w, 0, sizeof(*w));
> + if (!fmt) {
> + if (!user_format)
> + return;
> + fmt = user_format;
> + }
> + strbuf_expand(&dummy, user_format, userformat_want_item, w);
> + strbuf_release(&dummy);
> +}It does not matter for the current set of callers, but it might make sense to make it the responsibility of the caller to clear *w instead of unconditionally clearing what have been accumulated in there by previous calls to this function. It is not entirely implausible for a new caller to have more than one user formats, it uses one or more on the same commit depending on the context, and wants to find all the requirements by feeding the possible formats upfront to this function to fill a single *w structure.