@@ -1372,47 +1372,41 @@ static int get_mail_commit_oid(struct object_id *commit_id, const char *mail)
13721372 */
13731373static void get_commit_info (struct am_state * state , struct commit * commit )
13741374{
1375- const char * buffer , * ident_line , * author_date , * msg ;
1375+ const char * buffer , * ident_line , * msg ;
13761376 size_t ident_len ;
1377- struct ident_split ident_split ;
1378- struct strbuf sb = STRBUF_INIT ;
1377+ struct ident_split id ;
13791378
13801379 buffer = logmsg_reencode (commit , NULL , get_commit_output_encoding ());
13811380
13821381 ident_line = find_commit_header (buffer , "author" , & ident_len );
13831382
1384- if (split_ident_line (& ident_split , ident_line , ident_len ) < 0 ) {
1385- strbuf_add (& sb , ident_line , ident_len );
1386- die (_ ("invalid ident line: %s" ), sb .buf );
1387- }
1383+ if (split_ident_line (& id , ident_line , ident_len ) < 0 )
1384+ die (_ ("invalid ident line: %.*s" ), (int )ident_len , ident_line );
13881385
13891386 assert (!state -> author_name );
1390- if (ident_split .name_begin ) {
1391- strbuf_add (& sb , ident_split .name_begin ,
1392- ident_split .name_end - ident_split .name_begin );
1393- state -> author_name = strbuf_detach (& sb , NULL );
1394- } else
1387+ if (id .name_begin )
1388+ state -> author_name =
1389+ xmemdupz (id .name_begin , id .name_end - id .name_begin );
1390+ else
13951391 state -> author_name = xstrdup ("" );
13961392
13971393 assert (!state -> author_email );
1398- if (ident_split .mail_begin ) {
1399- strbuf_add (& sb , ident_split .mail_begin ,
1400- ident_split .mail_end - ident_split .mail_begin );
1401- state -> author_email = strbuf_detach (& sb , NULL );
1402- } else
1394+ if (id .mail_begin )
1395+ state -> author_email =
1396+ xmemdupz (id .mail_begin , id .mail_end - id .mail_begin );
1397+ else
14031398 state -> author_email = xstrdup ("" );
14041399
1405- author_date = show_ident_date (& ident_split , DATE_MODE (NORMAL ));
1406- strbuf_addstr (& sb , author_date );
14071400 assert (!state -> author_date );
1408- state -> author_date = strbuf_detach ( & sb , NULL );
1401+ state -> author_date = xstrdup ( show_ident_date ( & id , DATE_MODE ( NORMAL )) );
14091402
14101403 assert (!state -> msg );
14111404 msg = strstr (buffer , "\n\n" );
14121405 if (!msg )
14131406 die (_ ("unable to parse commit %s" ), oid_to_hex (& commit -> object .oid ));
14141407 state -> msg = xstrdup (msg + 2 );
14151408 state -> msg_len = strlen (state -> msg );
1409+ unuse_commit_buffer (commit , buffer );
14161410}
14171411
14181412/**
0 commit comments