git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
	Taylor Blau <me@ttaylorr.com>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH 4/4] config API: don't use vreportf(), make it static in usage.c
Date: Tue, 07 Dec 2021 19:05:39 +0100	[thread overview]
Message-ID: <211207.86fsr4nvbk.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <xmqqfsr5e87e.fsf@gitster.g>


On Mon, Dec 06 2021, Junio C Hamano wrote:

> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> In preceding commits the rest of the vreportf() users outside of
>> usage.c have been migrated to die_message(), leaving only the
>> git_die_config() function added in 5a80e97c827 (config: add
>> `git_die_config()` to the config-set API, 2014-08-07).
>>
>> Let's have its callers call error() themselves if they want to emit a
>> message, which is exactly what git_die_config() was doing for them
>> before emitting its own die() message.
>
> I do not quite get this.  If git_die_config() has been showing the
> message for them, and if the existing callers can just use error(),
> why not git_die_config() call error() on behalf of these callers?
>
>> diff --git a/builtin/fast-import.c b/builtin/fast-import.c
>> index 2b2e28bad79..4e2432bb491 100644
>> --- a/builtin/fast-import.c
>> +++ b/builtin/fast-import.c
>> @@ -3456,9 +3456,10 @@ static void git_pack_config(void)
>>  	}
>>  	if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
>>  		pack_idx_opts.version = indexversion_value;
>> -		if (pack_idx_opts.version > 2)
>> -			git_die_config("pack.indexversion",
>> -					"bad pack.indexversion=%"PRIu32, pack_idx_opts.version);
>> +		if (pack_idx_opts.version > 2) {
>> +			error("bad pack.indexversion=%"PRIu32, pack_idx_opts.version);
>> +			git_die_config("pack.indexversion");
>> +		}
>
> This is exactly what triggered the question above, and the pattern
> repeats elsewhere, too.
>
>> @@ -2550,18 +2552,12 @@ void git_die_config_linenr(const char *key, const char *filename, int linenr)
>>  		    key, filename, linenr);
>>  }
>>  
>> -NORETURN __attribute__((format(printf, 2, 3)))
>> -void git_die_config(const char *key, const char *err, ...)
>> +NORETURN
>> +void git_die_config(const char *key)
>>  {
>>  	const struct string_list *values;
>>  	struct key_value_info *kv_info;
>>  
>> -	if (err) {
>> -		va_list params;
>> -		va_start(params, err);
>> -		vreportf("error: ", err, params);
>> -		va_end(params);
>
> I get that we do not want to expose vreportf() to this caller, and I
> agree with the goal, but wouldn't it be the matter of calling
> get_error_routine() and calling it with err and params here, instead
> of losing the whole block?  Is that insufficient to avoid toucing
> all the callers?

I'll fix that in the incoming re-roll. This really didn't belong in this
series but a later one.

FWIW that change was because like this we'll accurately report the
source of the "error" when the function learns to spew <file>:<line> at
the user.

But for now I'll just have it do as you suggest...

  reply	other threads:[~2021-12-07 18:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 16:55 [PATCH 0/4] usage API: Add and use die_message() Ævar Arnfjörð Bjarmason
2021-12-06 16:55 ` [PATCH 1/4] usage.c: add a die_message() routine Ævar Arnfjörð Bjarmason
2021-12-06 19:42   ` Junio C Hamano
2021-12-06 19:46     ` Junio C Hamano
2021-12-06 16:55 ` [PATCH 2/4] usage.c API users: use die_message() where appropriate Ævar Arnfjörð Bjarmason
2021-12-06 20:00   ` Junio C Hamano
2021-12-06 16:55 ` [PATCH 3/4] usage.c + gc: add and use a die_message_errno() Ævar Arnfjörð Bjarmason
2021-12-06 21:19   ` Junio C Hamano
2021-12-06 16:55 ` [PATCH 4/4] config API: don't use vreportf(), make it static in usage.c Ævar Arnfjörð Bjarmason
2021-12-06 21:26   ` Junio C Hamano
2021-12-07 18:05     ` Ævar Arnfjörð Bjarmason [this message]
2021-12-07 18:26 ` [PATCH v2 0/6] usage API: Add and use die_message() Ævar Arnfjörð Bjarmason
2021-12-07 18:26   ` [PATCH v2 1/6] usage.c: add a die_message() routine Ævar Arnfjörð Bjarmason
2021-12-07 18:26   ` [PATCH v2 2/6] usage.c API users: use die_message() for "fatal :" + exit 128 Ævar Arnfjörð Bjarmason
2021-12-07 18:26   ` [PATCH v2 3/6] usage.c API users: use die_message() for error() " Ævar Arnfjörð Bjarmason
2021-12-07 18:26   ` [PATCH v2 4/6] gc: return from cmd_gc(), don't call exit() Ævar Arnfjörð Bjarmason
2021-12-07 18:26   ` [PATCH v2 5/6] usage.c + gc: add and use a die_message_errno() Ævar Arnfjörð Bjarmason
2021-12-07 18:26   ` [PATCH v2 6/6] config API: use get_error_routine(), not vreportf() Ævar Arnfjörð Bjarmason
2021-12-07 21:24   ` [PATCH v2 0/6] usage API: Add and use die_message() Junio C Hamano
2021-12-22 18:57   ` Jonathan Tan
2021-12-22 19:59     ` Junio C Hamano
2021-12-24 17:01     ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=211207.86fsr4nvbk.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).