6
6
#include "diffcore.h"
7
7
#include "tag.h"
8
8
#include "blame.h"
9
+ #include "commit-slab.h"
10
+
11
+ define_commit_slab (blame_suspects , struct blame_origin * );
12
+ static struct blame_suspects blame_suspects ;
13
+
14
+ struct blame_origin * get_blame_suspects (struct commit * commit )
15
+ {
16
+ struct blame_origin * * result ;
17
+
18
+ result = blame_suspects_peek (& blame_suspects , commit );
19
+
20
+ return result ? * result : NULL ;
21
+ }
22
+
23
+ static void set_blame_suspects (struct commit * commit , struct blame_origin * origin )
24
+ {
25
+ * blame_suspects_at (& blame_suspects , commit ) = origin ;
26
+ }
9
27
10
28
void blame_origin_decref (struct blame_origin * o )
11
29
{
@@ -15,12 +33,12 @@ void blame_origin_decref(struct blame_origin *o)
15
33
blame_origin_decref (o -> previous );
16
34
free (o -> file .ptr );
17
35
/* Should be present exactly once in commit chain */
18
- for (p = o -> commit -> util ; p ; l = p , p = p -> next ) {
36
+ for (p = get_blame_suspects ( o -> commit ) ; p ; l = p , p = p -> next ) {
19
37
if (p == o ) {
20
38
if (l )
21
39
l -> next = p -> next ;
22
40
else
23
- o -> commit -> util = p -> next ;
41
+ set_blame_suspects ( o -> commit , p -> next ) ;
24
42
free (o );
25
43
return ;
26
44
}
@@ -41,8 +59,8 @@ static struct blame_origin *make_origin(struct commit *commit, const char *path)
41
59
FLEX_ALLOC_STR (o , path , path );
42
60
o -> commit = commit ;
43
61
o -> refcnt = 1 ;
44
- o -> next = commit -> util ;
45
- commit -> util = o ;
62
+ o -> next = get_blame_suspects ( commit ) ;
63
+ set_blame_suspects ( commit , o ) ;
46
64
return o ;
47
65
}
48
66
@@ -54,13 +72,13 @@ static struct blame_origin *get_origin(struct commit *commit, const char *path)
54
72
{
55
73
struct blame_origin * o , * l ;
56
74
57
- for (o = commit -> util , l = NULL ; o ; l = o , o = o -> next ) {
75
+ for (o = get_blame_suspects ( commit ) , l = NULL ; o ; l = o , o = o -> next ) {
58
76
if (!strcmp (o -> path , path )) {
59
77
/* bump to front */
60
78
if (l ) {
61
79
l -> next = o -> next ;
62
- o -> next = commit -> util ;
63
- commit -> util = o ;
80
+ o -> next = get_blame_suspects ( commit ) ;
81
+ set_blame_suspects ( commit , o ) ;
64
82
}
65
83
return blame_origin_incref (o );
66
84
}
@@ -478,7 +496,7 @@ static void queue_blames(struct blame_scoreboard *sb, struct blame_origin *porig
478
496
porigin -> suspects = blame_merge (porigin -> suspects , sorted );
479
497
else {
480
498
struct blame_origin * o ;
481
- for (o = porigin -> commit -> util ; o ; o = o -> next ) {
499
+ for (o = get_blame_suspects ( porigin -> commit ) ; o ; o = o -> next ) {
482
500
if (o -> suspects ) {
483
501
porigin -> suspects = sorted ;
484
502
return ;
@@ -525,7 +543,7 @@ static struct blame_origin *find_origin(struct commit *parent,
525
543
const char * paths [2 ];
526
544
527
545
/* First check any existing origins */
528
- for (porigin = parent -> util ; porigin ; porigin = porigin -> next )
546
+ for (porigin = get_blame_suspects ( parent ) ; porigin ; porigin = porigin -> next )
529
547
if (!strcmp (porigin -> path , origin -> path )) {
530
548
/*
531
549
* The same path between origin and its parent
@@ -1550,7 +1568,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)
1550
1568
1551
1569
while (commit ) {
1552
1570
struct blame_entry * ent ;
1553
- struct blame_origin * suspect = commit -> util ;
1571
+ struct blame_origin * suspect = get_blame_suspects ( commit ) ;
1554
1572
1555
1573
/* find one suspect to break down */
1556
1574
while (suspect && !suspect -> suspects )
@@ -1752,6 +1770,8 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam
1752
1770
struct commit * final_commit = NULL ;
1753
1771
enum object_type type ;
1754
1772
1773
+ init_blame_suspects (& blame_suspects );
1774
+
1755
1775
if (sb -> reverse && sb -> contents_from )
1756
1776
die (_ ("--contents and --reverse do not blend well." ));
1757
1777
@@ -1815,7 +1835,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam
1815
1835
}
1816
1836
1817
1837
if (is_null_oid (& sb -> final -> object .oid )) {
1818
- o = sb -> final -> util ;
1838
+ o = get_blame_suspects ( sb -> final ) ;
1819
1839
sb -> final_buf = xmemdupz (o -> file .ptr , o -> file .size );
1820
1840
sb -> final_buf_size = o -> file .size ;
1821
1841
}
0 commit comments