2 * Another stupid program, this one parsing the headers of an
3 * email to figure out authorship and subject
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";
14 int cmd_mailinfo(int argc, const char **argv, const char *prefix)
16 const char *def_charset;
19 char *msgfile, *patchfile;
23 def_charset = get_commit_output_encoding();
24 mi.metainfo_charset = def_charset;
26 while (1 < argc && argv[1][0] == '-') {
27 if (!strcmp(argv[1], "-k"))
29 else if (!strcmp(argv[1], "-b"))
30 mi.keep_non_patch_brackets_in_subject = 1;
31 else if (!strcmp(argv[1], "-m") || !strcmp(argv[1], "--message-id"))
32 mi.add_message_id = 1;
33 else if (!strcmp(argv[1], "-u"))
34 mi.metainfo_charset = def_charset;
35 else if (!strcmp(argv[1], "-n"))
36 mi.metainfo_charset = NULL;
37 else if (starts_with(argv[1], "--encoding="))
38 mi.metainfo_charset = argv[1] + 11;
39 else if (!strcmp(argv[1], "--scissors"))
41 else if (!strcmp(argv[1], "--no-scissors"))
43 else if (!strcmp(argv[1], "--no-inbody-headers"))
44 mi.use_inbody_headers = 0;
46 usage(mailinfo_usage);
51 usage(mailinfo_usage);
56 msgfile = prefix_filename(prefix, argv[1]);
57 patchfile = prefix_filename(prefix, argv[2]);
59 status = !!mailinfo(&mi, msgfile, patchfile);