Re: [PATCH v2 04/13] config: format int64s gently
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 14, 2026, 00:42 UTC
- Message-ID
- <xmqq8qcwi29l.fsf@gitster.g>
- In-Reply-To
- <2bca4d231686e33ea9d4d85b10fcffd60a63ad46.1771026918.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 18 quoted lines
> +static int format_config_int64(struct strbuf *buf,
> + const char *key_,
> + const char *value_,
> + const struct key_value_info *kvi,
> + int gently)
> +{
> + int64_t v = 0;
> + if (gently) {
> + if (git_parse_int64(value_, &v))
> + return -1;
> + } else {
> + /* may die() */
> + v = git_config_int64(key_, value_ ? value_ : "", kvi);
> + }
> +
> + strbuf_addf(buf, "%"PRId64, v);
> + return 0;
> +}This establishes the pattern the next handful of patches follow. We already have in parse.c helpers that we can use for the gentler parsing, and otherwise we'd use git_config_*() that the caller of these new helpers were using originally.
I'd have preferred to have the blank line moved to the gap between the decl and the first statement, i.e.,
Show 13 quoted lines
> +{
> + int64_t v = 0;
> +
> + if (gently) {
> + if (git_parse_int64(value_, &v))
> + return -1;
> + } else {
> + /* may die() */
> + v = git_config_int64(key_, value_ ? value_ : "", kvi);
> + }
> + strbuf_addf(buf, "%"PRId64, v);
> + return 0;
> +}These "format X gently" steps look very good.