imap-send: improve error messages with configuration hints

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. Use the advise() API to display hints in a multi-line format with proper "hint:" prefixes for each line. Signed-off-by: Jörg Thalheim <joerg@thalheim.io> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jörg Thalheim committed Jun 20, 2025 at 17:56 UTC d30bf28d09d4d13ca7984d8593522be22f698f8a
1 file changed +7 -2
imap-send.c
+7 -2
@@ -25,6 +25,7 @@
25 #define DISABLE_SIGN_COMPARE_WARNINGS
26
27 #include "git-compat-util.h"
28 +#include "advice.h"
29 #include "config.h"
30 #include "credential.h"
31 #include "gettext.h"
@@ -1804,7 +1805,9 @@ int cmd_main(int argc, const char **argv)
1805
1806 if (!server.host) {
1807 if (!server.tunnel) {
1807 - fprintf(stderr, "no IMAP host specified\n");
1808 + error(_("no IMAP host specified"));
1809 + advise(_("set the IMAP host with 'git config imap.host <host>'.\n"
1810 + "(e.g., 'git config imap.host imaps://imap.example.com')"));
1811 ret = 1;
1812 goto out;
1813 }
@@ -1824,7 +1827,9 @@ int cmd_main(int argc, const char **argv)
1827 }
1828
1829 if (!server.folder) {
1827 - fprintf(stderr, "no IMAP folder specified\n");
1830 + error(_("no IMAP folder specified"));
1831 + advise(_("set the target folder with 'git config imap.folder <folder>'.\n"
1832 + "(e.g., 'git config imap.folder Drafts')"));
1833 ret = 1;
1834 goto out;
1835 }