77#include "object-name.h"
88#include "odb.h"
99#include "setup.h"
10-
11- char * git_mailmap_file ;
12- char * git_mailmap_blob ;
10+ #include "config.h"
1311
1412struct mailmap_info {
1513 char * name ;
@@ -183,7 +181,8 @@ static void read_mailmap_string(struct string_list *map, char *buf)
183181 }
184182}
185183
186- int read_mailmap_blob (struct string_list * map , const char * name )
184+ int read_mailmap_blob (struct repository * repo , struct string_list * map ,
185+ const char * name )
187186{
188187 struct object_id oid ;
189188 char * buf ;
@@ -192,10 +191,10 @@ int read_mailmap_blob(struct string_list *map, const char *name)
192191
193192 if (!name )
194193 return 0 ;
195- if (repo_get_oid (the_repository , name , & oid ) < 0 )
194+ if (repo_get_oid (repo , name , & oid ) < 0 )
196195 return 0 ;
197196
198- buf = odb_read_object (the_repository -> objects , & oid , & type , & size );
197+ buf = odb_read_object (repo -> objects , & oid , & type , & size );
199198 if (!buf )
200199 return error ("unable to read mailmap object at %s" , name );
201200 if (type != OBJ_BLOB ) {
@@ -209,23 +208,32 @@ int read_mailmap_blob(struct string_list *map, const char *name)
209208 return 0 ;
210209}
211210
212- int read_mailmap (struct string_list * map )
211+ int read_mailmap (struct repository * repo , struct string_list * map )
213212{
214213 int err = 0 ;
214+ char * mailmap_file = NULL , * mailmap_blob = NULL ;
215+
216+ repo_config_get_pathname (repo , "mailmap.file" , & mailmap_file );
217+ repo_config_get_string (repo , "mailmap.blob" , & mailmap_blob );
215218
216219 map -> strdup_strings = 1 ;
217220 map -> cmp = namemap_cmp ;
218221
219- if (!git_mailmap_blob && is_bare_repository ())
220- git_mailmap_blob = xstrdup ("HEAD:.mailmap" );
222+ if (!mailmap_blob && is_bare_repository ())
223+ mailmap_blob = xstrdup ("HEAD:.mailmap" );
221224
222225 if (!startup_info -> have_repository || !is_bare_repository ())
223226 err |= read_mailmap_file (map , ".mailmap" ,
224227 startup_info -> have_repository ?
225228 MAILMAP_NOFOLLOW : 0 );
226229 if (startup_info -> have_repository )
227- err |= read_mailmap_blob (map , git_mailmap_blob );
228- err |= read_mailmap_file (map , git_mailmap_file , 0 );
230+ err |= read_mailmap_blob (repo , map , mailmap_blob );
231+
232+ err |= read_mailmap_file (map , mailmap_file , 0 );
233+
234+ free (mailmap_file );
235+ free (mailmap_blob );
236+
229237 return err ;
230238}
231239
0 commit comments