@@ -1372,47 +1372,41 @@ static int get_mail_commit_oid(struct object_id *commit_id, const char *mail)
1372
1372
*/
1373
1373
static void get_commit_info (struct am_state * state , struct commit * commit )
1374
1374
{
1375
- const char * buffer , * ident_line , * author_date , * msg ;
1375
+ const char * buffer , * ident_line , * msg ;
1376
1376
size_t ident_len ;
1377
- struct ident_split ident_split ;
1378
- struct strbuf sb = STRBUF_INIT ;
1377
+ struct ident_split id ;
1379
1378
1380
1379
buffer = logmsg_reencode (commit , NULL , get_commit_output_encoding ());
1381
1380
1382
1381
ident_line = find_commit_header (buffer , "author" , & ident_len );
1383
1382
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 );
1388
1385
1389
1386
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
1395
1391
state -> author_name = xstrdup ("" );
1396
1392
1397
1393
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
1403
1398
state -> author_email = xstrdup ("" );
1404
1399
1405
- author_date = show_ident_date (& ident_split , DATE_MODE (NORMAL ));
1406
- strbuf_addstr (& sb , author_date );
1407
1400
assert (!state -> author_date );
1408
- state -> author_date = strbuf_detach ( & sb , NULL );
1401
+ state -> author_date = xstrdup ( show_ident_date ( & id , DATE_MODE ( NORMAL )) );
1409
1402
1410
1403
assert (!state -> msg );
1411
1404
msg = strstr (buffer , "\n\n" );
1412
1405
if (!msg )
1413
1406
die (_ ("unable to parse commit %s" ), oid_to_hex (& commit -> object .oid ));
1414
1407
state -> msg = xstrdup (msg + 2 );
1415
1408
state -> msg_len = strlen (state -> msg );
1409
+ unuse_commit_buffer (commit , buffer );
1416
1410
}
1417
1411
1418
1412
/**
0 commit comments