Skip to content

Commit 171dccd

Browse files
author
Junio C Hamano
committed
blame: cmp_suspect is not "cmp" anymore.
The earlier round makes the function return "is it different" and it does not return a value suitable for sorting anymore. Reverse the logic to return "are they the same suspect" instead, and rename it to "same_suspect()". Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 3254d21 commit 171dccd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

builtin-blame.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ struct scoreboard {
180180
int *lineno;
181181
};
182182

183-
static int cmp_suspect(struct origin *a, struct origin *b)
183+
static inline int same_suspect(struct origin *a, struct origin *b)
184184
{
185-
if (a->commit != b->commit)
185+
if (a == b)
186186
return 1;
187-
return strcmp(a->path, b->path);
187+
if (a->commit != b->commit)
188+
return 0;
189+
return !strcmp(a->path, b->path);
188190
}
189191

190-
#define cmp_suspect(a, b) ( ((a)==(b)) ? 0 : cmp_suspect(a,b) )
191-
192192
static void sanity_check_refcnt(struct scoreboard *);
193193

194194
/*
@@ -201,7 +201,7 @@ static void coalesce(struct scoreboard *sb)
201201
struct blame_entry *ent, *next;
202202

203203
for (ent = sb->ent; ent && (next = ent->next); ent = next) {
204-
if (!cmp_suspect(ent->suspect, next->suspect) &&
204+
if (same_suspect(ent->suspect, next->suspect) &&
205205
ent->guilty == next->guilty &&
206206
ent->s_lno + ent->num_lines == next->s_lno) {
207207
ent->num_lines += next->num_lines;
@@ -774,7 +774,7 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)
774774
int last_in_target = -1;
775775

776776
for (e = sb->ent; e; e = e->next) {
777-
if (e->guilty || cmp_suspect(e->suspect, target))
777+
if (e->guilty || !same_suspect(e->suspect, target))
778778
continue;
779779
if (last_in_target < e->s_lno + e->num_lines)
780780
last_in_target = e->s_lno + e->num_lines;
@@ -794,7 +794,7 @@ static void blame_chunk(struct scoreboard *sb,
794794
struct blame_entry *e;
795795

796796
for (e = sb->ent; e; e = e->next) {
797-
if (e->guilty || cmp_suspect(e->suspect, target))
797+
if (e->guilty || !same_suspect(e->suspect, target))
798798
continue;
799799
if (same <= e->s_lno)
800800
continue;
@@ -969,7 +969,7 @@ static int find_move_in_parent(struct scoreboard *sb,
969969
while (made_progress) {
970970
made_progress = 0;
971971
for (e = sb->ent; e; e = e->next) {
972-
if (e->guilty || cmp_suspect(e->suspect, target))
972+
if (e->guilty || !same_suspect(e->suspect, target))
973973
continue;
974974
find_copy_in_blob(sb, e, parent, split, &file_p);
975975
if (split[1].suspect &&
@@ -1001,12 +1001,12 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
10011001
struct blame_list *blame_list = NULL;
10021002

10031003
for (e = sb->ent, num_ents = 0; e; e = e->next)
1004-
if (!e->guilty && !cmp_suspect(e->suspect, target))
1004+
if (!e->guilty && same_suspect(e->suspect, target))
10051005
num_ents++;
10061006
if (num_ents) {
10071007
blame_list = xcalloc(num_ents, sizeof(struct blame_list));
10081008
for (e = sb->ent, i = 0; e; e = e->next)
1009-
if (!e->guilty && !cmp_suspect(e->suspect, target))
1009+
if (!e->guilty && same_suspect(e->suspect, target))
10101010
blame_list[i++].ent = e;
10111011
}
10121012
*num_ents_p = num_ents;
@@ -1136,7 +1136,7 @@ static void pass_whole_blame(struct scoreboard *sb,
11361136
origin->file.ptr = NULL;
11371137
}
11381138
for (e = sb->ent; e; e = e->next) {
1139-
if (cmp_suspect(e->suspect, origin))
1139+
if (!same_suspect(e->suspect, origin))
11401140
continue;
11411141
origin_incref(porigin);
11421142
origin_decref(e->suspect);
@@ -1442,7 +1442,7 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
14421442

14431443
/* Take responsibility for the remaining entries */
14441444
for (ent = sb->ent; ent; ent = ent->next)
1445-
if (!cmp_suspect(ent->suspect, suspect))
1445+
if (same_suspect(ent->suspect, suspect))
14461446
found_guilty_entry(ent);
14471447
origin_decref(suspect);
14481448

0 commit comments

Comments
 (0)