@matheusbsbs / matheus-bagliano / commits / f1f909e318
Fork 0

mailinfo: Use i18n.commitencoding

This uses i18n.commitencoding configuration item to pick up the default commit encoding for the repository when converting form e-mail encoding to commit encoding (the default is utf8). Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 27, 2005 at 16:29 UTC f1f909e3185b5ee366e198042447afe749bfc813
1 file changed +9 -8
mailinfo.c
+9 -8
@@ -8,6 +8,7 @@
8 #include <string.h>
9 #include <ctype.h>
10 #include <iconv.h>
11 +#include "cache.h"
12
13 #ifdef NO_STRCASESTR
14 extern char *gitstrcasestr(const char *haystack, const char *needle);
@@ -718,27 +719,27 @@ static void handle_body(void)
719 static const char mailinfo_usage[] =
720 "git-mailinfo [-k] [-u] msg patch <mail >info";
721
721 -static void usage(void) {
722 - fprintf(stderr, "%s\n", mailinfo_usage);
723 - exit(1);
724 -}
725 -
722 int main(int argc, char **argv)
723 {
724 + /* NEEDSWORK: might want to do the optional .git/ directory
725 + * discovery
726 + */
727 + git_config(git_default_config);
728 +
729 while (1 < argc && argv[1][0] == '-') {
730 if (!strcmp(argv[1], "-k"))
731 keep_subject = 1;
732 else if (!strcmp(argv[1], "-u"))
732 - metainfo_charset = "utf-8";
733 + metainfo_charset = git_commit_encoding;
734 else if (!strncmp(argv[1], "-u=", 3))
735 metainfo_charset = argv[1] + 3;
736 else
736 - usage();
737 + usage(mailinfo_usage);
738 argc--; argv++;
739 }
740
741 if (argc != 3)
741 - usage();
742 + usage(mailinfo_usage);
743 cmitmsg = fopen(argv[1], "w");
744 if (!cmitmsg) {
745 perror(argv[1]);