blame: move reverse flag to scoreboard
The reverse flag is used in parts of blame that are being moved to libgit, and should be accessible via the scoreboard structure. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Smith committed
May 24, 2017 at 00:15 UTC
f81d70e94010bd0a137249fcf16e15bd4e3d722a
1 file changed
+14
-9
builtin/blame.c
+14
-9
@@ -381,6 +381,9 @@ struct blame_scoreboard {
381
382
/* use this file's contents as the final image */
383
const char *contents_from;
384
+
385
+ /* flags */
386
+ int reverse;
387
};
388
389
static void sanity_check_refcnt(struct blame_scoreboard *);
@@ -1339,7 +1342,8 @@ static void pass_whole_blame(struct blame_scoreboard *sb,
1342
* "parent" (and "porigin"), but what we mean is to find scapegoat to
1343
* exonerate ourselves.
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)
1347
{
1348
if (!reverse) {
1349
if (revs->first_parent_only &&
@@ -1353,9 +1357,9 @@ static struct commit_list *first_scapegoat(struct rev_info *revs, struct commit
1357
return lookup_decoration(&revs->children, &commit->object);
1358
}
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)
1361
{
1358
- struct commit_list *l = first_scapegoat(revs, commit);
1362
+ struct commit_list *l = first_scapegoat(revs, commit, reverse);
1363
return commit_list_count(l);
1364
}
1365
@@ -1393,7 +1397,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1397
struct blame_entry *toosmall = NULL;
1398
struct blame_entry *blames, **blametail = &blames;
1399
1396
- num_sg = num_scapegoats(revs, commit);
1400
+ num_sg = num_scapegoats(revs, commit, sb->reverse);
1401
if (!num_sg)
1402
goto finish;
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,
1413
struct blame_origin *(*find)(struct commit *, struct blame_origin *);
1414
find = pass ? find_rename : find_origin;
1415
1412
- for (i = 0, sg = first_scapegoat(revs, commit);
1416
+ for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
1417
i < num_sg && sg;
1418
sg = sg->next, i++) {
1419
struct commit *p = sg->item;
@@ -1441,7 +1445,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1445
}
1446
1447
sb->num_commits++;
1444
- for (i = 0, sg = first_scapegoat(revs, commit);
1448
+ for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
1449
i < num_sg && sg;
1450
sg = sg->next, i++) {
1451
struct blame_origin *porigin = sg_origin[i];
@@ -1462,7 +1466,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1466
if (opt & PICKAXE_BLAME_MOVE) {
1467
filter_small(sb, &toosmall, &origin->suspects, sb->move_score);
1468
if (origin->suspects) {
1465
- for (i = 0, sg = first_scapegoat(revs, commit);
1469
+ for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
1470
i < num_sg && sg;
1471
sg = sg->next, i++) {
1472
struct blame_origin *porigin = sg_origin[i];
@@ -1489,7 +1493,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1493
if (!origin->suspects)
1494
goto finish;
1495
1492
- for (i = 0, sg = first_scapegoat(revs, commit);
1496
+ for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
1497
i < num_sg && sg;
1498
sg = sg->next, i++) {
1499
struct blame_origin *porigin = sg_origin[i];
@@ -1770,7 +1774,7 @@ static void assign_blame(struct blame_scoreboard *sb, int opt)
1774
*/
1775
blame_origin_incref(suspect);
1776
parse_commit(commit);
1773
- if (reverse ||
1777
+ if (sb->reverse ||
1778
(!(commit->object.flags & UNINTERESTING) &&
1779
!(revs->max_age != -1 && commit->date < revs->max_age)))
1780
pass_blame(sb, suspect, opt);
@@ -2739,6 +2743,7 @@ parse_done:
2743
2744
sb.revs = &revs;
2745
sb.contents_from = contents_from;
2746
+ sb.reverse = reverse;
2747
if (!reverse) {
2748
final_commit_name = prepare_final(&sb);
2749
sb.commits.compare = compare_commits_by_commit_date;