@@ -381,6 +381,9 @@ struct blame_scoreboard {
381
381
382
382
/* use this file's contents as the final image */
383
383
const char * contents_from ;
384
+
385
+ /* flags */
386
+ int reverse ;
384
387
};
385
388
386
389
static void sanity_check_refcnt (struct blame_scoreboard * );
@@ -1339,7 +1342,8 @@ static void pass_whole_blame(struct blame_scoreboard *sb,
1339
1342
* "parent" (and "porigin"), but what we mean is to find scapegoat to
1340
1343
* exonerate ourselves.
1341
1344
*/
1342
- static struct commit_list * first_scapegoat (struct rev_info * revs , struct commit * commit )
1345
+ static struct commit_list * first_scapegoat (struct rev_info * revs , struct commit * commit ,
1346
+ int reverse )
1343
1347
{
1344
1348
if (!reverse ) {
1345
1349
if (revs -> first_parent_only &&
@@ -1353,9 +1357,9 @@ static struct commit_list *first_scapegoat(struct rev_info *revs, struct commit
1353
1357
return lookup_decoration (& revs -> children , & commit -> object );
1354
1358
}
1355
1359
1356
- static int num_scapegoats (struct rev_info * revs , struct commit * commit )
1360
+ static int num_scapegoats (struct rev_info * revs , struct commit * commit , int reverse )
1357
1361
{
1358
- struct commit_list * l = first_scapegoat (revs , commit );
1362
+ struct commit_list * l = first_scapegoat (revs , commit , reverse );
1359
1363
return commit_list_count (l );
1360
1364
}
1361
1365
@@ -1393,7 +1397,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1393
1397
struct blame_entry * toosmall = NULL ;
1394
1398
struct blame_entry * blames , * * blametail = & blames ;
1395
1399
1396
- num_sg = num_scapegoats (revs , commit );
1400
+ num_sg = num_scapegoats (revs , commit , sb -> reverse );
1397
1401
if (!num_sg )
1398
1402
goto finish ;
1399
1403
else if (num_sg < ARRAY_SIZE (sg_buf ))
@@ -1409,7 +1413,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1409
1413
struct blame_origin * (* find )(struct commit * , struct blame_origin * );
1410
1414
find = pass ? find_rename : find_origin ;
1411
1415
1412
- for (i = 0 , sg = first_scapegoat (revs , commit );
1416
+ for (i = 0 , sg = first_scapegoat (revs , commit , sb -> reverse );
1413
1417
i < num_sg && sg ;
1414
1418
sg = sg -> next , i ++ ) {
1415
1419
struct commit * p = sg -> item ;
@@ -1441,7 +1445,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1441
1445
}
1442
1446
1443
1447
sb -> num_commits ++ ;
1444
- for (i = 0 , sg = first_scapegoat (revs , commit );
1448
+ for (i = 0 , sg = first_scapegoat (revs , commit , sb -> reverse );
1445
1449
i < num_sg && sg ;
1446
1450
sg = sg -> next , i ++ ) {
1447
1451
struct blame_origin * porigin = sg_origin [i ];
@@ -1462,7 +1466,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1462
1466
if (opt & PICKAXE_BLAME_MOVE ) {
1463
1467
filter_small (sb , & toosmall , & origin -> suspects , sb -> move_score );
1464
1468
if (origin -> suspects ) {
1465
- for (i = 0 , sg = first_scapegoat (revs , commit );
1469
+ for (i = 0 , sg = first_scapegoat (revs , commit , sb -> reverse );
1466
1470
i < num_sg && sg ;
1467
1471
sg = sg -> next , i ++ ) {
1468
1472
struct blame_origin * porigin = sg_origin [i ];
@@ -1489,7 +1493,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1489
1493
if (!origin -> suspects )
1490
1494
goto finish ;
1491
1495
1492
- for (i = 0 , sg = first_scapegoat (revs , commit );
1496
+ for (i = 0 , sg = first_scapegoat (revs , commit , sb -> reverse );
1493
1497
i < num_sg && sg ;
1494
1498
sg = sg -> next , i ++ ) {
1495
1499
struct blame_origin * porigin = sg_origin [i ];
@@ -1770,7 +1774,7 @@ static void assign_blame(struct blame_scoreboard *sb, int opt)
1770
1774
*/
1771
1775
blame_origin_incref (suspect );
1772
1776
parse_commit (commit );
1773
- if (reverse ||
1777
+ if (sb -> reverse ||
1774
1778
(!(commit -> object .flags & UNINTERESTING ) &&
1775
1779
!(revs -> max_age != -1 && commit -> date < revs -> max_age )))
1776
1780
pass_blame (sb , suspect , opt );
@@ -2739,6 +2743,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2739
2743
2740
2744
sb .revs = & revs ;
2741
2745
sb .contents_from = contents_from ;
2746
+ sb .reverse = reverse ;
2742
2747
if (!reverse ) {
2743
2748
final_commit_name = prepare_final (& sb );
2744
2749
sb .commits .compare = compare_commits_by_commit_date ;
0 commit comments