@@ -61,11 +61,6 @@ static struct string_list mailmap = STRING_LIST_INIT_NODUP;
61
61
#define DEBUG 0
62
62
#endif
63
63
64
- /* stats */
65
- static int num_read_blob ;
66
- static int num_get_patch ;
67
- static int num_commits ;
68
-
69
64
#define PICKAXE_BLAME_MOVE 01
70
65
#define PICKAXE_BLAME_COPY 02
71
66
#define PICKAXE_BLAME_COPY_HARDER 04
@@ -151,13 +146,13 @@ static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b,
151
146
* diff machinery
152
147
*/
153
148
static void fill_origin_blob (struct diff_options * opt ,
154
- struct blame_origin * o , mmfile_t * file )
149
+ struct blame_origin * o , mmfile_t * file , int * num_read_blob )
155
150
{
156
151
if (!o -> file .ptr ) {
157
152
enum object_type type ;
158
153
unsigned long file_size ;
159
154
160
- num_read_blob ++ ;
155
+ ( * num_read_blob ) ++ ;
161
156
if (DIFF_OPT_TST (opt , ALLOW_TEXTCONV ) &&
162
157
textconv_object (o -> path , o -> mode , & o -> blob_oid , 1 , & file -> ptr , & file_size ))
163
158
;
@@ -375,6 +370,11 @@ struct blame_scoreboard {
375
370
/* look-up a line in the final buffer */
376
371
int num_lines ;
377
372
int * lineno ;
373
+
374
+ /* stats */
375
+ int num_read_blob ;
376
+ int num_get_patch ;
377
+ int num_commits ;
378
378
};
379
379
380
380
static void sanity_check_refcnt (struct blame_scoreboard * );
@@ -934,9 +934,9 @@ static void pass_blame_to_parent(struct blame_scoreboard *sb,
934
934
d .offset = 0 ;
935
935
d .dstq = & newdest ; d .srcq = & target -> suspects ;
936
936
937
- fill_origin_blob (& sb -> revs -> diffopt , parent , & file_p );
938
- fill_origin_blob (& sb -> revs -> diffopt , target , & file_o );
939
- num_get_patch ++ ;
937
+ fill_origin_blob (& sb -> revs -> diffopt , parent , & file_p , & sb -> num_read_blob );
938
+ fill_origin_blob (& sb -> revs -> diffopt , target , & file_o , & sb -> num_read_blob );
939
+ sb -> num_get_patch ++ ;
940
940
941
941
if (diff_hunks (& file_p , & file_o , blame_chunk_cb , & d ))
942
942
die ("unable to generate diff (%s -> %s)" ,
@@ -1140,7 +1140,7 @@ static void find_move_in_parent(struct blame_scoreboard *sb,
1140
1140
if (!unblamed )
1141
1141
return ; /* nothing remains for this target */
1142
1142
1143
- fill_origin_blob (& sb -> revs -> diffopt , parent , & file_p );
1143
+ fill_origin_blob (& sb -> revs -> diffopt , parent , & file_p , & sb -> num_read_blob );
1144
1144
if (!file_p .ptr )
1145
1145
return ;
1146
1146
@@ -1269,7 +1269,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
1269
1269
norigin = get_origin (parent , p -> one -> path );
1270
1270
oidcpy (& norigin -> blob_oid , & p -> one -> oid );
1271
1271
norigin -> mode = p -> one -> mode ;
1272
- fill_origin_blob (& sb -> revs -> diffopt , norigin , & file_p );
1272
+ fill_origin_blob (& sb -> revs -> diffopt , norigin , & file_p , & sb -> num_read_blob );
1273
1273
if (!file_p .ptr )
1274
1274
continue ;
1275
1275
@@ -1434,7 +1434,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1434
1434
}
1435
1435
}
1436
1436
1437
- num_commits ++ ;
1437
+ sb -> num_commits ++ ;
1438
1438
for (i = 0 , sg = first_scapegoat (revs , commit );
1439
1439
i < num_sg && sg ;
1440
1440
sg = sg -> next , i ++ ) {
@@ -2818,7 +2818,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2818
2818
oid_to_hex (& o -> blob_oid ),
2819
2819
path );
2820
2820
}
2821
- num_read_blob ++ ;
2821
+ sb . num_read_blob ++ ;
2822
2822
lno = prepare_lines (& sb );
2823
2823
2824
2824
if (lno && !range_list .nr )
@@ -2899,9 +2899,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2899
2899
}
2900
2900
2901
2901
if (show_stats ) {
2902
- printf ("num read blob: %d\n" , num_read_blob );
2903
- printf ("num get patch: %d\n" , num_get_patch );
2904
- printf ("num commits: %d\n" , num_commits );
2902
+ printf ("num read blob: %d\n" , sb . num_read_blob );
2903
+ printf ("num get patch: %d\n" , sb . num_get_patch );
2904
+ printf ("num commits: %d\n" , sb . num_commits );
2905
2905
}
2906
2906
return 0 ;
2907
2907
}
0 commit comments