Skip to content

Commit 8449528

Browse files
whydoubtgitster
authored andcommitted
blame: move stat counters to scoreboard
Statistic counters are 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 935202b commit 8449528

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

builtin/blame.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ static struct string_list mailmap = STRING_LIST_INIT_NODUP;
6161
#define DEBUG 0
6262
#endif
6363

64-
/* stats */
65-
static int num_read_blob;
66-
static int num_get_patch;
67-
static int num_commits;
68-
6964
#define PICKAXE_BLAME_MOVE 01
7065
#define PICKAXE_BLAME_COPY 02
7166
#define PICKAXE_BLAME_COPY_HARDER 04
@@ -151,13 +146,13 @@ static int diff_hunks(mmfile_t *file_a, mmfile_t *file_b,
151146
* diff machinery
152147
*/
153148
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)
155150
{
156151
if (!o->file.ptr) {
157152
enum object_type type;
158153
unsigned long file_size;
159154

160-
num_read_blob++;
155+
(*num_read_blob)++;
161156
if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
162157
textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))
163158
;
@@ -375,6 +370,11 @@ struct blame_scoreboard {
375370
/* look-up a line in the final buffer */
376371
int num_lines;
377372
int *lineno;
373+
374+
/* stats */
375+
int num_read_blob;
376+
int num_get_patch;
377+
int num_commits;
378378
};
379379

380380
static void sanity_check_refcnt(struct blame_scoreboard *);
@@ -934,9 +934,9 @@ static void pass_blame_to_parent(struct blame_scoreboard *sb,
934934
d.offset = 0;
935935
d.dstq = &newdest; d.srcq = &target->suspects;
936936

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++;
940940

941941
if (diff_hunks(&file_p, &file_o, blame_chunk_cb, &d))
942942
die("unable to generate diff (%s -> %s)",
@@ -1140,7 +1140,7 @@ static void find_move_in_parent(struct blame_scoreboard *sb,
11401140
if (!unblamed)
11411141
return; /* nothing remains for this target */
11421142

1143-
fill_origin_blob(&sb->revs->diffopt, parent, &file_p);
1143+
fill_origin_blob(&sb->revs->diffopt, parent, &file_p, &sb->num_read_blob);
11441144
if (!file_p.ptr)
11451145
return;
11461146

@@ -1269,7 +1269,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
12691269
norigin = get_origin(parent, p->one->path);
12701270
oidcpy(&norigin->blob_oid, &p->one->oid);
12711271
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);
12731273
if (!file_p.ptr)
12741274
continue;
12751275

@@ -1434,7 +1434,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
14341434
}
14351435
}
14361436

1437-
num_commits++;
1437+
sb->num_commits++;
14381438
for (i = 0, sg = first_scapegoat(revs, commit);
14391439
i < num_sg && sg;
14401440
sg = sg->next, i++) {
@@ -2818,7 +2818,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
28182818
oid_to_hex(&o->blob_oid),
28192819
path);
28202820
}
2821-
num_read_blob++;
2821+
sb.num_read_blob++;
28222822
lno = prepare_lines(&sb);
28232823

28242824
if (lno && !range_list.nr)
@@ -2899,9 +2899,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
28992899
}
29002900

29012901
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);
29052905
}
29062906
return 0;
29072907
}

0 commit comments

Comments
 (0)