Skip to content

Commit 0af596c

Browse files
René Scharfegitster
authored andcommitted
blame: use hunk_func(), part 1
Use blame_chunk_cb() directly as hunk_func() callback, without detour through xdi_diff_hunks(). Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 467d348 commit 0af596c

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

builtin/blame.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,14 @@ struct blame_chunk_cb_data {
759759
long tlno;
760760
};
761761

762-
static void blame_chunk_cb(void *data, long same, long p_next, long t_next)
762+
static int blame_chunk_cb(long start_a, long count_a,
763+
long start_b, long count_b, void *data)
763764
{
764765
struct blame_chunk_cb_data *d = data;
765-
blame_chunk(d->sb, d->tlno, d->plno, same, d->target, d->parent);
766-
d->plno = p_next;
767-
d->tlno = t_next;
766+
blame_chunk(d->sb, d->tlno, d->plno, start_b, d->target, d->parent);
767+
d->plno = start_a + count_a;
768+
d->tlno = start_b + count_b;
769+
return 0;
768770
}
769771

770772
/*
@@ -781,6 +783,8 @@ static int pass_blame_to_parent(struct scoreboard *sb,
781783
struct blame_chunk_cb_data d;
782784
xpparam_t xpp;
783785
xdemitconf_t xecfg;
786+
xdemitcb_t ecb;
787+
784788
memset(&d, 0, sizeof(d));
785789
d.sb = sb; d.target = target; d.parent = parent;
786790
last_in_target = find_last_in_target(sb, target);
@@ -795,7 +799,10 @@ static int pass_blame_to_parent(struct scoreboard *sb,
795799
xpp.flags = xdl_opts;
796800
memset(&xecfg, 0, sizeof(xecfg));
797801
xecfg.ctxlen = 0;
798-
xdi_diff_hunks(&file_p, &file_o, blame_chunk_cb, &d, &xpp, &xecfg);
802+
xecfg.hunk_func = blame_chunk_cb;
803+
memset(&ecb, 0, sizeof(ecb));
804+
ecb.priv = &d;
805+
xdi_diff(&file_p, &file_o, &xpp, &xecfg, &ecb);
799806
/* The rest (i.e. anything after tlno) are the same as the parent */
800807
blame_chunk(sb, d.tlno, d.plno, last_in_target, target, parent);
801808

0 commit comments

Comments
 (0)