@@ -2396,16 +2396,11 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
2396
2396
return commit ;
2397
2397
}
2398
2398
2399
- static char * prepare_final (struct scoreboard * sb )
2399
+ static struct object_array_entry * find_single_final (struct rev_info * revs )
2400
2400
{
2401
2401
int i ;
2402
- const char * final_commit_name = NULL ;
2403
- struct rev_info * revs = sb -> revs ;
2402
+ struct object_array_entry * found = NULL ;
2404
2403
2405
- /*
2406
- * There must be one and only one positive commit in the
2407
- * revs->pending array.
2408
- */
2409
2404
for (i = 0 ; i < revs -> pending .nr ; i ++ ) {
2410
2405
struct object * obj = revs -> pending .objects [i ].item ;
2411
2406
if (obj -> flags & UNINTERESTING )
@@ -2414,14 +2409,24 @@ static char *prepare_final(struct scoreboard *sb)
2414
2409
obj = deref_tag (obj , NULL , 0 );
2415
2410
if (obj -> type != OBJ_COMMIT )
2416
2411
die ("Non commit %s?" , revs -> pending .objects [i ].name );
2417
- if (sb -> final )
2412
+ if (found )
2418
2413
die ("More than one commit to dig from %s and %s?" ,
2419
2414
revs -> pending .objects [i ].name ,
2420
- final_commit_name );
2421
- sb -> final = (struct commit * ) obj ;
2422
- final_commit_name = revs -> pending .objects [i ].name ;
2415
+ found -> name );
2416
+ found = & (revs -> pending .objects [i ]);
2417
+ }
2418
+ return found ;
2419
+ }
2420
+
2421
+ static char * prepare_final (struct scoreboard * sb )
2422
+ {
2423
+ struct object_array_entry * found = find_single_final (sb -> revs );
2424
+ if (found ) {
2425
+ sb -> final = (struct commit * ) found -> item ;
2426
+ return xstrdup (found -> name );
2427
+ } else {
2428
+ return NULL ;
2423
2429
}
2424
- return xstrdup_or_null (final_commit_name );
2425
2430
}
2426
2431
2427
2432
static char * prepare_initial (struct scoreboard * sb )
0 commit comments