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>
This commit is contained in:
Junio C Hamano 2007-03-20 23:37:51 -07:00
parent 3254d218b4
commit 171dccd511

View File

@ -180,15 +180,15 @@ struct scoreboard {
int *lineno; int *lineno;
}; };
static int cmp_suspect(struct origin *a, struct origin *b) static inline int same_suspect(struct origin *a, struct origin *b)
{ {
if (a->commit != b->commit) if (a == b)
return 1; return 1;
return strcmp(a->path, b->path); if (a->commit != b->commit)
return 0;
return !strcmp(a->path, b->path);
} }
#define cmp_suspect(a, b) ( ((a)==(b)) ? 0 : cmp_suspect(a,b) )
static void sanity_check_refcnt(struct scoreboard *); static void sanity_check_refcnt(struct scoreboard *);
/* /*
@ -201,7 +201,7 @@ static void coalesce(struct scoreboard *sb)
struct blame_entry *ent, *next; struct blame_entry *ent, *next;
for (ent = sb->ent; ent && (next = ent->next); ent = next) { for (ent = sb->ent; ent && (next = ent->next); ent = next) {
if (!cmp_suspect(ent->suspect, next->suspect) && if (same_suspect(ent->suspect, next->suspect) &&
ent->guilty == next->guilty && ent->guilty == next->guilty &&
ent->s_lno + ent->num_lines == next->s_lno) { ent->s_lno + ent->num_lines == next->s_lno) {
ent->num_lines += next->num_lines; ent->num_lines += next->num_lines;
@ -774,7 +774,7 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)
int last_in_target = -1; int last_in_target = -1;
for (e = sb->ent; e; e = e->next) { for (e = sb->ent; e; e = e->next) {
if (e->guilty || cmp_suspect(e->suspect, target)) if (e->guilty || !same_suspect(e->suspect, target))
continue; continue;
if (last_in_target < e->s_lno + e->num_lines) if (last_in_target < e->s_lno + e->num_lines)
last_in_target = e->s_lno + e->num_lines; last_in_target = e->s_lno + e->num_lines;
@ -794,7 +794,7 @@ static void blame_chunk(struct scoreboard *sb,
struct blame_entry *e; struct blame_entry *e;
for (e = sb->ent; e; e = e->next) { for (e = sb->ent; e; e = e->next) {
if (e->guilty || cmp_suspect(e->suspect, target)) if (e->guilty || !same_suspect(e->suspect, target))
continue; continue;
if (same <= e->s_lno) if (same <= e->s_lno)
continue; continue;
@ -969,7 +969,7 @@ static int find_move_in_parent(struct scoreboard *sb,
while (made_progress) { while (made_progress) {
made_progress = 0; made_progress = 0;
for (e = sb->ent; e; e = e->next) { for (e = sb->ent; e; e = e->next) {
if (e->guilty || cmp_suspect(e->suspect, target)) if (e->guilty || !same_suspect(e->suspect, target))
continue; continue;
find_copy_in_blob(sb, e, parent, split, &file_p); find_copy_in_blob(sb, e, parent, split, &file_p);
if (split[1].suspect && if (split[1].suspect &&
@ -1001,12 +1001,12 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
struct blame_list *blame_list = NULL; struct blame_list *blame_list = NULL;
for (e = sb->ent, num_ents = 0; e; e = e->next) for (e = sb->ent, num_ents = 0; e; e = e->next)
if (!e->guilty && !cmp_suspect(e->suspect, target)) if (!e->guilty && same_suspect(e->suspect, target))
num_ents++; num_ents++;
if (num_ents) { if (num_ents) {
blame_list = xcalloc(num_ents, sizeof(struct blame_list)); blame_list = xcalloc(num_ents, sizeof(struct blame_list));
for (e = sb->ent, i = 0; e; e = e->next) for (e = sb->ent, i = 0; e; e = e->next)
if (!e->guilty && !cmp_suspect(e->suspect, target)) if (!e->guilty && same_suspect(e->suspect, target))
blame_list[i++].ent = e; blame_list[i++].ent = e;
} }
*num_ents_p = num_ents; *num_ents_p = num_ents;
@ -1136,7 +1136,7 @@ static void pass_whole_blame(struct scoreboard *sb,
origin->file.ptr = NULL; origin->file.ptr = NULL;
} }
for (e = sb->ent; e; e = e->next) { for (e = sb->ent; e; e = e->next) {
if (cmp_suspect(e->suspect, origin)) if (!same_suspect(e->suspect, origin))
continue; continue;
origin_incref(porigin); origin_incref(porigin);
origin_decref(e->suspect); origin_decref(e->suspect);
@ -1442,7 +1442,7 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
/* Take responsibility for the remaining entries */ /* Take responsibility for the remaining entries */
for (ent = sb->ent; ent; ent = ent->next) for (ent = sb->ent; ent; ent = ent->next)
if (!cmp_suspect(ent->suspect, suspect)) if (same_suspect(ent->suspect, suspect))
found_guilty_entry(ent); found_guilty_entry(ent);
origin_decref(suspect); origin_decref(suspect);