@@ -66,10 +66,6 @@ static struct string_list mailmap = STRING_LIST_INIT_NODUP;
66
66
#define PICKAXE_BLAME_COPY_HARDER 04
67
67
#define PICKAXE_BLAME_COPY_HARDEST 010
68
68
69
- /*
70
- * blame for a blame_entry with score lower than these thresholds
71
- * is not passed to the parent using move/copy logic.
72
- */
73
69
static unsigned blame_move_score ;
74
70
static unsigned blame_copy_score ;
75
71
#define BLAME_DEFAULT_MOVE_SCORE 20
@@ -375,6 +371,13 @@ struct blame_scoreboard {
375
371
int num_read_blob ;
376
372
int num_get_patch ;
377
373
int num_commits ;
374
+
375
+ /*
376
+ * blame for a blame_entry with score lower than these thresholds
377
+ * is not passed to the parent using move/copy logic.
378
+ */
379
+ unsigned move_score ;
380
+ unsigned copy_score ;
378
381
};
379
382
380
383
static void sanity_check_refcnt (struct blame_scoreboard * );
@@ -1156,7 +1159,7 @@ static void find_move_in_parent(struct blame_scoreboard *sb,
1156
1159
next = e -> next ;
1157
1160
find_copy_in_blob (sb , e , parent , split , & file_p );
1158
1161
if (split [1 ].suspect &&
1159
- blame_move_score < blame_entry_score (sb , & split [1 ])) {
1162
+ sb -> move_score < blame_entry_score (sb , & split [1 ])) {
1160
1163
split_blame (blamed , & unblamedtail , split , e );
1161
1164
} else {
1162
1165
e -> next = leftover ;
@@ -1165,7 +1168,7 @@ static void find_move_in_parent(struct blame_scoreboard *sb,
1165
1168
decref_split (split );
1166
1169
}
1167
1170
* unblamedtail = NULL ;
1168
- toosmall = filter_small (sb , toosmall , & unblamed , blame_move_score );
1171
+ toosmall = filter_small (sb , toosmall , & unblamed , sb -> move_score );
1169
1172
} while (unblamed );
1170
1173
target -> suspects = reverse_blame (leftover , NULL );
1171
1174
}
@@ -1286,7 +1289,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
1286
1289
for (j = 0 ; j < num_ents ; j ++ ) {
1287
1290
struct blame_entry * split = blame_list [j ].split ;
1288
1291
if (split [1 ].suspect &&
1289
- blame_copy_score < blame_entry_score (sb , & split [1 ])) {
1292
+ sb -> copy_score < blame_entry_score (sb , & split [1 ])) {
1290
1293
split_blame (blamed , & unblamedtail , split ,
1291
1294
blame_list [j ].ent );
1292
1295
} else {
@@ -1297,7 +1300,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
1297
1300
}
1298
1301
free (blame_list );
1299
1302
* unblamedtail = NULL ;
1300
- toosmall = filter_small (sb , toosmall , & unblamed , blame_copy_score );
1303
+ toosmall = filter_small (sb , toosmall , & unblamed , sb -> copy_score );
1301
1304
} while (unblamed );
1302
1305
target -> suspects = reverse_blame (leftover , NULL );
1303
1306
diff_flush (& diff_opts );
@@ -1454,7 +1457,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1454
1457
* Optionally find moves in parents' files.
1455
1458
*/
1456
1459
if (opt & PICKAXE_BLAME_MOVE ) {
1457
- filter_small (sb , & toosmall , & origin -> suspects , blame_move_score );
1460
+ filter_small (sb , & toosmall , & origin -> suspects , sb -> move_score );
1458
1461
if (origin -> suspects ) {
1459
1462
for (i = 0 , sg = first_scapegoat (revs , commit );
1460
1463
i < num_sg && sg ;
@@ -1473,12 +1476,12 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
1473
1476
* Optionally find copies from parents' files.
1474
1477
*/
1475
1478
if (opt & PICKAXE_BLAME_COPY ) {
1476
- if (blame_copy_score > blame_move_score )
1477
- filter_small (sb , & toosmall , & origin -> suspects , blame_copy_score );
1478
- else if (blame_copy_score < blame_move_score ) {
1479
+ if (sb -> copy_score > sb -> move_score )
1480
+ filter_small (sb , & toosmall , & origin -> suspects , sb -> copy_score );
1481
+ else if (sb -> copy_score < sb -> move_score ) {
1479
1482
origin -> suspects = blame_merge (origin -> suspects , toosmall );
1480
1483
toosmall = NULL ;
1481
- filter_small (sb , & toosmall , & origin -> suspects , blame_copy_score );
1484
+ filter_small (sb , & toosmall , & origin -> suspects , sb -> copy_score );
1482
1485
}
1483
1486
if (!origin -> suspects )
1484
1487
goto finish ;
@@ -2675,11 +2678,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2675
2678
opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |
2676
2679
PICKAXE_BLAME_COPY_HARDER );
2677
2680
2678
- if (!blame_move_score )
2679
- blame_move_score = BLAME_DEFAULT_MOVE_SCORE ;
2680
- if (!blame_copy_score )
2681
- blame_copy_score = BLAME_DEFAULT_COPY_SCORE ;
2682
-
2683
2681
/*
2684
2682
* We have collected options unknown to us in argv[1..unk]
2685
2683
* which are to be passed to revision machinery if we are
@@ -2733,6 +2731,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2733
2731
revs .disable_stdin = 1 ;
2734
2732
setup_revisions (argc , argv , & revs , NULL );
2735
2733
memset (& sb , 0 , sizeof (sb ));
2734
+ sb .move_score = BLAME_DEFAULT_MOVE_SCORE ;
2735
+ sb .copy_score = BLAME_DEFAULT_COPY_SCORE ;
2736
2736
2737
2737
sb .revs = & revs ;
2738
2738
if (!reverse ) {
@@ -2871,6 +2871,11 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2871
2871
sb .ent = NULL ;
2872
2872
sb .path = path ;
2873
2873
2874
+ if (blame_move_score )
2875
+ sb .move_score = blame_move_score ;
2876
+ if (blame_copy_score )
2877
+ sb .copy_score = blame_copy_score ;
2878
+
2874
2879
read_mailmap (& mailmap , NULL );
2875
2880
2876
2881
assign_blame (& sb , opt );
0 commit comments