@@ -2402,10 +2402,12 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
2402
2402
return commit ;
2403
2403
}
2404
2404
2405
- static struct object_array_entry * find_single_final (struct rev_info * revs )
2405
+ static struct commit * find_single_final (struct rev_info * revs ,
2406
+ const char * * name_p )
2406
2407
{
2407
2408
int i ;
2408
- struct object_array_entry * found = NULL ;
2409
+ struct commit * found = NULL ;
2410
+ const char * name = NULL ;
2409
2411
2410
2412
for (i = 0 ; i < revs -> pending .nr ; i ++ ) {
2411
2413
struct object * obj = revs -> pending .objects [i ].item ;
@@ -2417,22 +2419,20 @@ static struct object_array_entry *find_single_final(struct rev_info *revs)
2417
2419
die ("Non commit %s?" , revs -> pending .objects [i ].name );
2418
2420
if (found )
2419
2421
die ("More than one commit to dig from %s and %s?" ,
2420
- revs -> pending .objects [i ].name ,
2421
- found -> name ) ;
2422
- found = & ( revs -> pending .objects [i ]) ;
2422
+ revs -> pending .objects [i ].name , name );
2423
+ found = ( struct commit * ) obj ;
2424
+ name = revs -> pending .objects [i ]. name ;
2423
2425
}
2426
+ if (name_p )
2427
+ * name_p = name ;
2424
2428
return found ;
2425
2429
}
2426
2430
2427
2431
static char * prepare_final (struct scoreboard * sb )
2428
2432
{
2429
- struct object_array_entry * found = find_single_final (sb -> revs );
2430
- if (found ) {
2431
- sb -> final = (struct commit * ) found -> item ;
2432
- return xstrdup (found -> name );
2433
- } else {
2434
- return NULL ;
2435
- }
2433
+ const char * name ;
2434
+ sb -> final = find_single_final (sb -> revs , & name );
2435
+ return xstrdup_or_null (name );
2436
2436
}
2437
2437
2438
2438
static char * prepare_initial (struct scoreboard * sb )
@@ -2720,11 +2720,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2720
2720
die ("Cannot use --contents with final commit object name" );
2721
2721
2722
2722
if (reverse && revs .first_parent_only ) {
2723
- struct object_array_entry * entry = find_single_final (sb .revs );
2724
- if (!entry )
2723
+ final_commit = find_single_final (sb .revs , NULL );
2724
+ if (!final_commit )
2725
2725
die ("--reverse and --first-parent together require specified latest commit" );
2726
- else
2727
- final_commit = (struct commit * ) entry -> item ;
2728
2726
}
2729
2727
2730
2728
/*
0 commit comments