{"thread":{"id":"2695","subject":"[PATCH 3/3] mailinfo: Use i18n.commitencoding","startedAt":"2005-11-28T00:39:22Z","lastAt":"2005-11-28T00:39:22Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"12828","messageId":"7v1x1161xh.fsf@assigned-by-dhcp.cox.net","threadId":"2695","inReplyTo":null,"subject":"[PATCH 3/3] mailinfo: Use i18n.commitencoding","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-28T00:39:22Z","receivedAt":"2005-11-28T00:39:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This uses i18n.commitencoding configuration item to pick up the\ndefault commit encoding for the repository when converting form\ne-mail encoding to commit encoding (the default is utf8).\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * I am not very thrilled with doing this change to mailinfo;\n   alternatively the wrapper could read the configuration and\n   decide what encoding to pass with -u=encoding flag.\n\n mailinfo.c |   17 +++++++++--------\n 1 files changed, 9 insertions(+), 8 deletions(-)\n\napplies-to: dab00e61bbd43be526bce908d4142d7c80d7a325\nf1f909e3185b5ee366e198042447afe749bfc813\ndiff --git a/mailinfo.c b/mailinfo.c\nindex 6d8c933..de105ac 100644\n--- a/mailinfo.c\n+++ b/mailinfo.c\n@@ -8,6 +8,7 @@\n #include <string.h>\n #include <ctype.h>\n #include <iconv.h>\n+#include \"cache.h\"\n \n #ifdef NO_STRCASESTR\n extern char *gitstrcasestr(const char *haystack, const char *needle);\n@@ -718,27 +719,27 @@ static void handle_body(void)\n static const char mailinfo_usage[] =\n \t\"git-mailinfo [-k] [-u] msg patch <mail >info\";\n \n-static void usage(void) {\n-\tfprintf(stderr, \"%s\\n\", mailinfo_usage);\n-\texit(1);\n-}\n-\n int main(int argc, char **argv)\n {\n+\t/* NEEDSWORK: might want to do the optional .git/ directory\n+\t * discovery\n+\t */\n+\tgit_config(git_default_config);\n+\n \twhile (1 < argc && argv[1][0] == '-') {\n \t\tif (!strcmp(argv[1], \"-k\"))\n \t\t\tkeep_subject = 1;\n \t\telse if (!strcmp(argv[1], \"-u\"))\n-\t\t\tmetainfo_charset = \"utf-8\";\n+\t\t\tmetainfo_charset = git_commit_encoding;\n \t\telse if (!strncmp(argv[1], \"-u=\", 3))\n \t\t\tmetainfo_charset = argv[1] + 3;\n \t\telse\n-\t\t\tusage();\n+\t\t\tusage(mailinfo_usage);\n \t\targc--; argv++;\n \t}\n \n \tif (argc != 3)\n-\t\tusage();\n+\t\tusage(mailinfo_usage);\n \tcmitmsg = fopen(argv[1], \"w\");\n \tif (!cmitmsg) {\n \t\tperror(argv[1]);\n---\n0.99.9.GIT\n"}]}