From: Junio C Hamano <gitster@pobox.com>
To: Joerg Thalheim <joerg@thalheim.io>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
Aditya Garg <gargaditya08@live.com>
Subject: Re: [PATCH v2 2/2] imap-send: improve error messages with configuration hints
Date: Fri, 20 Jun 2025 08:44:21 -0700 [thread overview]
Message-ID: <xmqqldpm4duy.fsf@gitster.g> (raw)
In-Reply-To: <20250620063836.252881-3-joerg@thalheim.io> (Joerg Thalheim's message of "Fri, 20 Jun 2025 08:38:36 +0200")
Joerg Thalheim <joerg@thalheim.io> writes:
> From: Jörg Thalheim <joerg@thalheim.io>
>
> Replace basic error messages with more helpful ones that guide users
> on how to resolve configuration issues. When imap.host or imap.folder
> are missing, provide the exact git config commands needed to fix the
> problem, along with examples of typical values.
>
> This uses the advise() API to display hints that can be disabled
> by users who don't want them,
Not quite. We do not encourage or condone wholesale disabling of
all advise messages by end users. The advice_if_enabled() helper
allows selective disabling of individual messages that the user has
seen often enough and find no more need for help, but I do not think
it is advisable (no pun intended) to use it in these particular code
paths, simply because once the relevant configuration variables are
set, the users will not see the errors anymore.
The reason advise() was suggested was primarily because of its
better handling of multi-line messages. It can be fed a multi-line
message (i.e., with embedded LF in it), and give "hint:" prefix to
each line, which is lacking from the error(), warning(), die() family
of messaging functions.
> + error(_("no IMAP host specified"));
> + advise(_("set the IMAP host with 'git config imap.host <host>'"));
> + advise(_("(e.g., 'git config imap.host imaps://imap.example.com')"));
Give a single multi-line message to a single advise() call, i.e.,
advice(_("set the IMAP host with ... <host>'.\n"
"(e.g., 'git config ....com')"));
instead of two back-to-back calls to advise. It allows the
translators to find points to break lines better than the programmer
who wrote these advise() call(s).
> @@ -1831,7 +1834,9 @@ int cmd_main(int argc, const char **argv)
> }
>
> if (!server.folder) {
> - fprintf(stderr, "no IMAP folder specified\n");
> + error(_("no IMAP folder specified"));
> + advise(_("set the target folder with 'git config imap.folder <folder>'"));
> + advise(_("(e.g., 'git config imap.folder Drafts')"));
Ditto.
As a #leftoverbit we might want to inspect many fprintf(stderr)
still remain in this program after this patch and turn them into
calls to appropriate error() or warning() or whatever, but that
certainly would be outside the scope of this patch.
Thanks.
next prev parent reply other threads:[~2025-06-20 15:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 8:53 [PATCH] imap-send: improve error messages for missing configuration Jörg Thalheim
2025-06-20 0:58 ` Junio C Hamano
2025-06-20 5:03 ` Aditya Garg
2025-06-20 5:05 ` Aditya Garg
2025-06-20 6:38 ` [PATCH v2 0/2] " Joerg Thalheim
2025-06-20 6:38 ` [PATCH v2 1/2] imap-send: fix confusing 'store' terminology in error message Joerg Thalheim
2025-06-20 6:38 ` [PATCH v2 2/2] imap-send: improve error messages with configuration hints Joerg Thalheim
2025-06-20 15:44 ` Junio C Hamano [this message]
2025-06-20 15:56 ` [PATCH v3 0/2] imap-send: improve error messages for missing configuration Joerg Thalheim
2025-06-20 15:56 ` [PATCH v3 1/2] imap-send: fix confusing 'store' terminology in error message Joerg Thalheim
2025-06-20 15:56 ` [PATCH v3 2/2] imap-send: improve error messages with configuration hints Joerg Thalheim
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=xmqqldpm4duy.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=gargaditya08@live.com \
--cc=git@vger.kernel.org \
--cc=joerg@thalheim.io \
--cc=ps@pks.im \
/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).