Git fork

check-mailmap: add options for additional mailmap sources

The git check-mailmap command reads the mailmap from either the default
.mailmap location and then from the mailmap.blob and mailmap.file
configurations.

A following change to git send-email will want to support new
configuration options based on the configured identity. The
identity-based configuration and options only make sense in the context
of git send-email.

Expose the read_mailmap_file and read_mailmap_blob functions from
mailmap.c. Teach git check-mailmap the --mailmap-file and
--mailmap-blob options which load the additional mailmap sources.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Jacob Keller and committed by
Junio C Hamano
f54ca6ae 3a27e991

+27 -6
+10
Documentation/git-check-mailmap.txt
··· 27 27 Read contacts, one per line, from the standard input after exhausting 28 28 contacts provided on the command-line. 29 29 30 + --mailmap-file=<file>:: 31 + In addition to any configured mailmap files, read the specified 32 + mailmap file. Entries in this file take precedence over entries in 33 + either the default mailmap file or any configured mailmap file. 34 + 35 + --mailmap-blob=<blob>:: 36 + Like `--mailmap-file`, but consider the value as a reference to a 37 + blob in the repository. If both `--mailmap-file` and 38 + `--mailmap-blob` are specified, entries in `--mailmap-file` will 39 + take precedence. 30 40 31 41 OUTPUT 32 42 ------
+7
builtin/check-mailmap.c
··· 9 9 #include "write-or-die.h" 10 10 11 11 static int use_stdin; 12 + static const char *mailmap_file, *mailmap_blob; 12 13 static const char * const check_mailmap_usage[] = { 13 14 N_("git check-mailmap [<options>] <contact>..."), 14 15 NULL ··· 16 17 17 18 static const struct option check_mailmap_options[] = { 18 19 OPT_BOOL(0, "stdin", &use_stdin, N_("also read contacts from stdin")), 20 + OPT_FILENAME(0, "mailmap-file", &mailmap_file, N_("read additional mailmap entries from file")), 21 + OPT_STRING(0, "mailmap-blob", &mailmap_blob, N_("blob"), N_("read additional mailmap entries from blob")), 19 22 OPT_END() 20 23 }; 21 24 ··· 56 59 die(_("no contacts specified")); 57 60 58 61 read_mailmap(&mailmap); 62 + if (mailmap_blob) 63 + read_mailmap_blob(&mailmap, mailmap_blob); 64 + if (mailmap_file) 65 + read_mailmap_file(&mailmap, mailmap_file, 0); 59 66 60 67 for (i = 0; i < argc; ++i) 61 68 check_mailmap(&mailmap, argv[i]);
+3 -6
mailmap.c
··· 142 142 add_mapping(map, name1, email1, name2, email2); 143 143 } 144 144 145 - /* Flags for read_mailmap_file() */ 146 - #define MAILMAP_NOFOLLOW (1<<0) 147 - 148 - static int read_mailmap_file(struct string_list *map, const char *filename, 149 - unsigned flags) 145 + int read_mailmap_file(struct string_list *map, const char *filename, 146 + unsigned flags) 150 147 { 151 148 char buffer[1024]; 152 149 FILE *f; ··· 186 183 } 187 184 } 188 185 189 - static int read_mailmap_blob(struct string_list *map, const char *name) 186 + int read_mailmap_blob(struct string_list *map, const char *name) 190 187 { 191 188 struct object_id oid; 192 189 char *buf;
+7
mailmap.h
··· 6 6 extern char *git_mailmap_file; 7 7 extern char *git_mailmap_blob; 8 8 9 + /* Flags for read_mailmap_file() */ 10 + #define MAILMAP_NOFOLLOW (1<<0) 11 + 12 + int read_mailmap_file(struct string_list *map, const char *filename, 13 + unsigned flags); 14 + int read_mailmap_blob(struct string_list *map, const char *name); 15 + 9 16 int read_mailmap(struct string_list *map); 10 17 void clear_mailmap(struct string_list *map); 11 18