l10n: zh_CN: review for git v2.10.0 l10n
[git] / builtin / mailinfo.c
1 /*
2  * Another stupid program, this one parsing the headers of an
3  * email to figure out authorship and subject
4  */
5 #include "cache.h"
6 #include "builtin.h"
7 #include "utf8.h"
8 #include "strbuf.h"
9 #include "mailinfo.h"
10
11 static const char mailinfo_usage[] =
12         "git mailinfo [-k | -b] [-m | --message-id] [-u | --encoding=<encoding> | -n] [--scissors | --no-scissors] <msg> <patch> < mail >info";
13
14 int cmd_mailinfo(int argc, const char **argv, const char *prefix)
15 {
16         const char *def_charset;
17         struct mailinfo mi;
18         int status;
19
20         /* NEEDSWORK: might want to do the optional .git/ directory
21          * discovery
22          */
23         setup_mailinfo(&mi);
24
25         def_charset = get_commit_output_encoding();
26         mi.metainfo_charset = def_charset;
27
28         while (1 < argc && argv[1][0] == '-') {
29                 if (!strcmp(argv[1], "-k"))
30                         mi.keep_subject = 1;
31                 else if (!strcmp(argv[1], "-b"))
32                         mi.keep_non_patch_brackets_in_subject = 1;
33                 else if (!strcmp(argv[1], "-m") || !strcmp(argv[1], "--message-id"))
34                         mi.add_message_id = 1;
35                 else if (!strcmp(argv[1], "-u"))
36                         mi.metainfo_charset = def_charset;
37                 else if (!strcmp(argv[1], "-n"))
38                         mi.metainfo_charset = NULL;
39                 else if (starts_with(argv[1], "--encoding="))
40                         mi.metainfo_charset = argv[1] + 11;
41                 else if (!strcmp(argv[1], "--scissors"))
42                         mi.use_scissors = 1;
43                 else if (!strcmp(argv[1], "--no-scissors"))
44                         mi.use_scissors = 0;
45                 else if (!strcmp(argv[1], "--no-inbody-headers"))
46                         mi.use_inbody_headers = 0;
47                 else
48                         usage(mailinfo_usage);
49                 argc--; argv++;
50         }
51
52         if (argc != 3)
53                 usage(mailinfo_usage);
54
55         mi.input = stdin;
56         mi.output = stdout;
57         status = !!mailinfo(&mi, argv[1], argv[2]);
58         clear_mailinfo(&mi);
59
60         return status;
61 }