From e675765235001c382ba30d336bb69618296c012b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 21 Sep 2018 17:57:24 +0200 Subject: diff.c: remove implicit dependency on the_index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A new variant repo_diff_setup() is added that takes 'struct repository *' and diff_setup() becomes a thin macro around it that is protected by NO_THE_REPOSITORY_COMPATIBILITY_MACROS, similar to NO_THE_INDEX_.... The plan is these macros will always be defined for all library files and the macros are only accessible in builtin/ Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- blame.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'blame.c') diff --git a/blame.c b/blame.c index 9d57c76baa..c229a10c0e 100644 --- a/blame.c +++ b/blame.c @@ -541,8 +541,9 @@ static int fill_blob_sha1_and_mode(struct repository *r, * We have an origin -- check if the same path exists in the * parent and return an origin structure to represent it. */ -static struct blame_origin *find_origin(struct commit *parent, - struct blame_origin *origin) +static struct blame_origin *find_origin(struct repository *r, + struct commit *parent, + struct blame_origin *origin) { struct blame_origin *porigin; struct diff_options diff_opts; @@ -562,7 +563,7 @@ static struct blame_origin *find_origin(struct commit *parent, * and origin first. Most of the time they are the * same and diff-tree is fairly efficient about this. */ - diff_setup(&diff_opts); + repo_diff_setup(r, &diff_opts); diff_opts.flags.recursive = 1; diff_opts.detect_rename = 0; diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; @@ -629,14 +630,15 @@ static struct blame_origin *find_origin(struct commit *parent, * We have an origin -- find the path that corresponds to it in its * parent and return an origin structure to represent it. */ -static struct blame_origin *find_rename(struct commit *parent, - struct blame_origin *origin) +static struct blame_origin *find_rename(struct repository *r, + struct commit *parent, + struct blame_origin *origin) { struct blame_origin *porigin = NULL; struct diff_options diff_opts; int i; - diff_setup(&diff_opts); + repo_diff_setup(r, &diff_opts); diff_opts.flags.recursive = 1; diff_opts.detect_rename = DIFF_DETECT_RENAME; diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; @@ -1260,7 +1262,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb, if (!unblamed) return; /* nothing remains for this target */ - diff_setup(&diff_opts); + repo_diff_setup(sb->repo, &diff_opts); diff_opts.flags.recursive = 1; diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; @@ -1442,7 +1444,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin, * common cases, then we look for renames in the second pass. */ for (pass = 0; pass < 2 - sb->no_whole_file_rename; pass++) { - struct blame_origin *(*find)(struct commit *, struct blame_origin *); + struct blame_origin *(*find)(struct repository *, struct commit *, struct blame_origin *); find = pass ? find_rename : find_origin; for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse); @@ -1455,7 +1457,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin, continue; if (parse_commit(p)) continue; - porigin = find(p, origin); + porigin = find(sb->repo, p, origin); if (!porigin) continue; if (!oidcmp(&porigin->blob_oid, &origin->blob_oid)) { -- cgit v1.2.3