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>
Junio C Hamano committed
Mar 20, 2007 at 23:37 UTC
171dccd511bb4642e4491dc5115549b67a859a5b
1 file changed
+13
-13
builtin-blame.c
+13
-13
@@ -180,15 +180,15 @@ struct scoreboard {
180
int *lineno;
181
};
182
183
-static int cmp_suspect(struct origin *a, struct origin *b)
183
+static inline int same_suspect(struct origin *a, struct origin *b)
184
{
185
- if (a->commit != b->commit)
185
+ if (a == b)
186
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);
190
}
191
190
-#define cmp_suspect(a, b) ( ((a)==(b)) ? 0 : cmp_suspect(a,b) )
191
-
192
static void sanity_check_refcnt(struct scoreboard *);
193
194
/*
@@ -201,7 +201,7 @@ static void coalesce(struct scoreboard *sb)
201
struct blame_entry *ent, *next;
202
203
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) &&
205
ent->guilty == next->guilty &&
206
ent->s_lno + ent->num_lines == next->s_lno) {
207
ent->num_lines += next->num_lines;
@@ -774,7 +774,7 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)
774
int last_in_target = -1;
775
776
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))
778
continue;
779
if (last_in_target < e->s_lno + e->num_lines)
780
last_in_target = e->s_lno + e->num_lines;
@@ -794,7 +794,7 @@ static void blame_chunk(struct scoreboard *sb,
794
struct blame_entry *e;
795
796
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))
798
continue;
799
if (same <= e->s_lno)
800
continue;
@@ -969,7 +969,7 @@ static int find_move_in_parent(struct scoreboard *sb,
969
while (made_progress) {
970
made_progress = 0;
971
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))
973
continue;
974
find_copy_in_blob(sb, e, parent, split, &file_p);
975
if (split[1].suspect &&
@@ -1001,12 +1001,12 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
1001
struct blame_list *blame_list = NULL;
1002
1003
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))
1005
num_ents++;
1006
if (num_ents) {
1007
blame_list = xcalloc(num_ents, sizeof(struct blame_list));
1008
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))
1010
blame_list[i++].ent = e;
1011
}
1012
*num_ents_p = num_ents;
@@ -1136,7 +1136,7 @@ static void pass_whole_blame(struct scoreboard *sb,
1136
origin->file.ptr = NULL;
1137
}
1138
for (e = sb->ent; e; e = e->next) {
1139
- if (cmp_suspect(e->suspect, origin))
1139
+ if (!same_suspect(e->suspect, origin))
1140
continue;
1141
origin_incref(porigin);
1142
origin_decref(e->suspect);
@@ -1442,7 +1442,7 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
1442
1443
/* Take responsibility for the remaining entries */
1444
for (ent = sb->ent; ent; ent = ent->next)
1445
- if (!cmp_suspect(ent->suspect, suspect))
1445
+ if (same_suspect(ent->suspect, suspect))
1446
found_guilty_entry(ent);
1447
origin_decref(suspect);
1448