@@ -2396,16 +2396,11 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
23962396 return commit ;
23972397}
23982398
2399- static char * prepare_final (struct scoreboard * sb )
2399+ static struct object_array_entry * find_single_final (struct rev_info * revs )
24002400{
24012401 int i ;
2402- const char * final_commit_name = NULL ;
2403- struct rev_info * revs = sb -> revs ;
2402+ struct object_array_entry * found = NULL ;
24042403
2405- /*
2406- * There must be one and only one positive commit in the
2407- * revs->pending array.
2408- */
24092404 for (i = 0 ; i < revs -> pending .nr ; i ++ ) {
24102405 struct object * obj = revs -> pending .objects [i ].item ;
24112406 if (obj -> flags & UNINTERESTING )
@@ -2414,14 +2409,24 @@ static char *prepare_final(struct scoreboard *sb)
24142409 obj = deref_tag (obj , NULL , 0 );
24152410 if (obj -> type != OBJ_COMMIT )
24162411 die ("Non commit %s?" , revs -> pending .objects [i ].name );
2417- if (sb -> final )
2412+ if (found )
24182413 die ("More than one commit to dig from %s and %s?" ,
24192414 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 ;
24232429 }
2424- return xstrdup_or_null (final_commit_name );
24252430}
24262431
24272432static char * prepare_initial (struct scoreboard * sb )
0 commit comments