summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-09-21 15:57:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-09-21 16:50:58 (GMT)
commitacd00ea04998ce469d1775c658134b097e18f5a3 (patch)
tree67703a7f2647ac72b45103a65d102a7203dabd6e /diff.c
parent35843b1123e2772c5db6d7db5abf279c3253ae57 (diff)
downloadgit-acd00ea04998ce469d1775c658134b097e18f5a3.zip
git-acd00ea04998ce469d1775c658134b097e18f5a3.tar.gz
git-acd00ea04998ce469d1775c658134b097e18f5a3.tar.bz2
userdiff.c: remove implicit dependency on the_index
[jc: squashed in missing forward decl in userdiff.h found by Ramsay] Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/diff.c b/diff.c
index 140d0e8..5256b9e 100644
--- a/diff.c
+++ b/diff.c
@@ -2093,23 +2093,25 @@ static void diff_words_flush(struct emit_callback *ecbdata)
}
}
-static void diff_filespec_load_driver(struct diff_filespec *one)
+static void diff_filespec_load_driver(struct diff_filespec *one,
+ struct index_state *istate)
{
/* Use already-loaded driver */
if (one->driver)
return;
if (S_ISREG(one->mode))
- one->driver = userdiff_find_by_path(one->path);
+ one->driver = userdiff_find_by_path(istate, one->path);
/* Fallback to default settings */
if (!one->driver)
one->driver = userdiff_find_by_name("default");
}
-static const char *userdiff_word_regex(struct diff_filespec *one)
+static const char *userdiff_word_regex(struct diff_filespec *one,
+ struct index_state *istate)
{
- diff_filespec_load_driver(one);
+ diff_filespec_load_driver(one, istate);
return one->driver->word_regex;
}
@@ -2132,9 +2134,9 @@ static void init_diff_words_data(struct emit_callback *ecbdata,
xcalloc(1, sizeof(struct emitted_diff_symbols));
if (!o->word_regex)
- o->word_regex = userdiff_word_regex(one);
+ o->word_regex = userdiff_word_regex(one, o->repo->index);
if (!o->word_regex)
- o->word_regex = userdiff_word_regex(two);
+ o->word_regex = userdiff_word_regex(two, o->repo->index);
if (!o->word_regex)
o->word_regex = diff_word_regex_cfg;
if (o->word_regex) {
@@ -3257,7 +3259,7 @@ int diff_filespec_is_binary(struct repository *r,
struct diff_filespec *one)
{
if (one->is_binary == -1) {
- diff_filespec_load_driver(one);
+ diff_filespec_load_driver(one, r->index);
if (one->driver->binary != -1)
one->is_binary = one->driver->binary;
else {
@@ -3273,9 +3275,10 @@ int diff_filespec_is_binary(struct repository *r,
return one->is_binary;
}
-static const struct userdiff_funcname *diff_funcname_pattern(struct diff_filespec *one)
+static const struct userdiff_funcname *
+diff_funcname_pattern(struct diff_options *o, struct diff_filespec *one)
{
- diff_filespec_load_driver(one);
+ diff_filespec_load_driver(one, o->repo->index);
return one->driver->funcname.pattern ? &one->driver->funcname : NULL;
}
@@ -3287,12 +3290,13 @@ void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const
options->b_prefix = b;
}
-struct userdiff_driver *get_textconv(struct diff_filespec *one)
+struct userdiff_driver *get_textconv(struct index_state *istate,
+ struct diff_filespec *one)
{
if (!DIFF_FILE_VALID(one))
return NULL;
- diff_filespec_load_driver(one);
+ diff_filespec_load_driver(one, istate);
return userdiff_get_textconv(one->driver);
}
@@ -3342,8 +3346,8 @@ static void builtin_diff(const char *name_a,
}
if (o->flags.allow_textconv) {
- textconv_one = get_textconv(one);
- textconv_two = get_textconv(two);
+ textconv_one = get_textconv(o->repo->index, one);
+ textconv_two = get_textconv(o->repo->index, two);
}
/* Never use a non-valid filename anywhere if at all possible */
@@ -3465,9 +3469,9 @@ static void builtin_diff(const char *name_a,
mf1.size = fill_textconv(o->repo, textconv_one, one, &mf1.ptr);
mf2.size = fill_textconv(o->repo, textconv_two, two, &mf2.ptr);
- pe = diff_funcname_pattern(one);
+ pe = diff_funcname_pattern(o, one);
if (!pe)
- pe = diff_funcname_pattern(two);
+ pe = diff_funcname_pattern(o, two);
memset(&xpp, 0, sizeof(xpp));
memset(&xecfg, 0, sizeof(xecfg));
@@ -4223,7 +4227,9 @@ static void run_diff_cmd(const char *pgm,
if (o->flags.allow_external) {
- struct userdiff_driver *drv = userdiff_find_by_path(attr_path);
+ struct userdiff_driver *drv;
+
+ drv = userdiff_find_by_path(o->repo->index, attr_path);
if (drv && drv->external)
pgm = drv->external;
}
@@ -6399,7 +6405,7 @@ int textconv_object(struct repository *r,
df = alloc_filespec(path);
fill_filespec(df, oid, oid_valid, mode);
- textconv = get_textconv(df);
+ textconv = get_textconv(r->index, df);
if (!textconv) {
free_filespec(df);
return 0;