99#include "setup.h"
1010#include "config.h"
1111
12+ void mailmap_init (struct mailmap * map )
13+ {
14+ struct mailmap blank = MAILMAP_INIT ;
15+ memcpy (map , & blank , sizeof (* map ));
16+ }
17+
1218struct mailmap_info {
1319 char * name ;
1420 char * email ;
@@ -56,7 +62,7 @@ static int namemap_cmp(const char *a, const char *b)
5662 return strcasecmp (a , b );
5763}
5864
59- static void add_mapping (struct string_list * map ,
65+ static void add_mapping (struct mailmap * map ,
6066 char * new_name , char * new_email ,
6167 char * old_name , char * old_email )
6268{
@@ -68,7 +74,7 @@ static void add_mapping(struct string_list *map,
6874 new_email = NULL ;
6975 }
7076
71- item = string_list_insert (map , old_email );
77+ item = string_list_insert (& map -> map , old_email );
7278 if (item -> util ) {
7379 me = (struct mailmap_entry * )item -> util ;
7480 } else {
@@ -125,7 +131,7 @@ static char *parse_name_and_email(char *buffer, char **name,
125131 return (* right == '\0' ? NULL : right );
126132}
127133
128- static void read_mailmap_line (struct string_list * map , char * buffer )
134+ static void read_mailmap_line (struct mailmap * map , char * buffer )
129135{
130136 char * name1 = NULL , * email1 = NULL , * name2 = NULL , * email2 = NULL ;
131137
@@ -139,7 +145,7 @@ static void read_mailmap_line(struct string_list *map, char *buffer)
139145 add_mapping (map , name1 , email1 , name2 , email2 );
140146}
141147
142- int read_mailmap_file (struct string_list * map , const char * filename ,
148+ int read_mailmap_file (struct mailmap * map , const char * filename ,
143149 unsigned flags )
144150{
145151 char buffer [1024 ];
@@ -167,7 +173,7 @@ int read_mailmap_file(struct string_list *map, const char *filename,
167173 return 0 ;
168174}
169175
170- static void read_mailmap_string (struct string_list * map , char * buf )
176+ static void read_mailmap_string (struct mailmap * map , char * buf )
171177{
172178 while (* buf ) {
173179 char * end = strchrnul (buf , '\n' );
@@ -180,7 +186,7 @@ static void read_mailmap_string(struct string_list *map, char *buf)
180186 }
181187}
182188
183- int read_mailmap_blob (struct repository * repo , struct string_list * map ,
189+ int read_mailmap_blob (struct repository * repo , struct mailmap * map ,
184190 const char * name )
185191{
186192 struct object_id oid ;
@@ -207,16 +213,16 @@ int read_mailmap_blob(struct repository *repo, struct string_list *map,
207213 return 0 ;
208214}
209215
210- int read_mailmap (struct repository * repo , struct string_list * map )
216+ int read_mailmap (struct repository * repo , struct mailmap * map )
211217{
212218 int err = 0 ;
213219 char * mailmap_file = NULL , * mailmap_blob = NULL ;
214220
215221 repo_config_get_pathname (repo , "mailmap.file" , & mailmap_file );
216222 repo_config_get_string (repo , "mailmap.blob" , & mailmap_blob );
217223
218- string_list_init_dup (map );
219- map -> cmp = namemap_cmp ;
224+ string_list_init_dup (& map -> map );
225+ map -> map . cmp = namemap_cmp ;
220226
221227 if (!mailmap_blob && is_bare_repository ())
222228 mailmap_blob = xstrdup ("HEAD:.mailmap" );
@@ -236,9 +242,9 @@ int read_mailmap(struct repository *repo, struct string_list *map)
236242 return err ;
237243}
238244
239- void clear_mailmap (struct string_list * map )
245+ void clear_mailmap (struct mailmap * map )
240246{
241- string_list_clear_func (map , free_mailmap_entry );
247+ string_list_clear_func (& map -> map , free_mailmap_entry );
242248}
243249
244250/*
@@ -291,14 +297,14 @@ static struct string_list_item *lookup_prefix(struct string_list *map,
291297 return NULL ;
292298}
293299
294- int map_user (struct string_list * map ,
300+ int map_user (struct mailmap * map ,
295301 const char * * email , size_t * emaillen ,
296302 const char * * name , size_t * namelen )
297303{
298304 struct string_list_item * item ;
299305 struct mailmap_entry * me ;
300306
301- item = lookup_prefix (map , * email , * emaillen );
307+ item = lookup_prefix (& map -> map , * email , * emaillen );
302308 if (item ) {
303309 me = (struct mailmap_entry * )item -> util ;
304310 if (me -> namemap .nr ) {
0 commit comments