Skip to content

Commit f81d70e

Browse files
whydoubtgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 84be875 commit f81d70e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

builtin/blame.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ struct blame_scoreboard {
381381

382382
/* use this file's contents as the final image */
383383
const char *contents_from;
384+
385+
/* flags */
386+
int reverse;
384387
};
385388

386389
static void sanity_check_refcnt(struct blame_scoreboard *);
@@ -1339,7 +1342,8 @@ static void pass_whole_blame(struct blame_scoreboard *sb,
13391342
* "parent" (and "porigin"), but what we mean is to find scapegoat to
13401343
* exonerate ourselves.
13411344
*/
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)
13431347
{
13441348
if (!reverse) {
13451349
if (revs->first_parent_only &&
@@ -1353,9 +1357,9 @@ static struct commit_list *first_scapegoat(struct rev_info *revs, struct commit
13531357
return lookup_decoration(&revs->children, &commit->object);
13541358
}
13551359

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)
13571361
{
1358-
struct commit_list *l = first_scapegoat(revs, commit);
1362+
struct commit_list *l = first_scapegoat(revs, commit, reverse);
13591363
return commit_list_count(l);
13601364
}
13611365

@@ -1393,7 +1397,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
13931397
struct blame_entry *toosmall = NULL;
13941398
struct blame_entry *blames, **blametail = &blames;
13951399

1396-
num_sg = num_scapegoats(revs, commit);
1400+
num_sg = num_scapegoats(revs, commit, sb->reverse);
13971401
if (!num_sg)
13981402
goto finish;
13991403
else if (num_sg < ARRAY_SIZE(sg_buf))
@@ -1409,7 +1413,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
14091413
struct blame_origin *(*find)(struct commit *, struct blame_origin *);
14101414
find = pass ? find_rename : find_origin;
14111415

1412-
for (i = 0, sg = first_scapegoat(revs, commit);
1416+
for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
14131417
i < num_sg && sg;
14141418
sg = sg->next, i++) {
14151419
struct commit *p = sg->item;
@@ -1441,7 +1445,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
14411445
}
14421446

14431447
sb->num_commits++;
1444-
for (i = 0, sg = first_scapegoat(revs, commit);
1448+
for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
14451449
i < num_sg && sg;
14461450
sg = sg->next, i++) {
14471451
struct blame_origin *porigin = sg_origin[i];
@@ -1462,7 +1466,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
14621466
if (opt & PICKAXE_BLAME_MOVE) {
14631467
filter_small(sb, &toosmall, &origin->suspects, sb->move_score);
14641468
if (origin->suspects) {
1465-
for (i = 0, sg = first_scapegoat(revs, commit);
1469+
for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
14661470
i < num_sg && sg;
14671471
sg = sg->next, i++) {
14681472
struct blame_origin *porigin = sg_origin[i];
@@ -1489,7 +1493,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
14891493
if (!origin->suspects)
14901494
goto finish;
14911495

1492-
for (i = 0, sg = first_scapegoat(revs, commit);
1496+
for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
14931497
i < num_sg && sg;
14941498
sg = sg->next, i++) {
14951499
struct blame_origin *porigin = sg_origin[i];
@@ -1770,7 +1774,7 @@ static void assign_blame(struct blame_scoreboard *sb, int opt)
17701774
*/
17711775
blame_origin_incref(suspect);
17721776
parse_commit(commit);
1773-
if (reverse ||
1777+
if (sb->reverse ||
17741778
(!(commit->object.flags & UNINTERESTING) &&
17751779
!(revs->max_age != -1 && commit->date < revs->max_age)))
17761780
pass_blame(sb, suspect, opt);
@@ -2739,6 +2743,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
27392743

27402744
sb.revs = &revs;
27412745
sb.contents_from = contents_from;
2746+
sb.reverse = reverse;
27422747
if (!reverse) {
27432748
final_commit_name = prepare_final(&sb);
27442749
sb.commits.compare = compare_commits_by_commit_date;

0 commit comments

Comments
 (0)