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>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2018-09-21 17:57:33 +02:00
committed by Junio C Hamano
parent 35843b1123
commit acd00ea049
11 changed files with 61 additions and 41 deletions

View File

@ -264,9 +264,10 @@ static int has_only_ascii(const char *s)
}
}
static int entry_is_binary(const char *path, const void *buffer, size_t size)
static int entry_is_binary(struct index_state *istate, const char *path,
const void *buffer, size_t size)
{
struct userdiff_driver *driver = userdiff_find_by_path(path);
struct userdiff_driver *driver = userdiff_find_by_path(istate, path);
if (!driver)
driver = userdiff_find_by_name("default");
if (driver->binary != -1)
@ -352,7 +353,8 @@ static int write_zip_entry(struct archiver_args *args,
return error(_("cannot read %s"),
oid_to_hex(oid));
crc = crc32(crc, buffer, size);
is_binary = entry_is_binary(path_without_prefix,
is_binary = entry_is_binary(args->repo->index,
path_without_prefix,
buffer, size);
out = buffer;
}
@ -428,7 +430,8 @@ static int write_zip_entry(struct archiver_args *args,
break;
crc = crc32(crc, buf, readlen);
if (is_binary == -1)
is_binary = entry_is_binary(path_without_prefix,
is_binary = entry_is_binary(args->repo->index,
path_without_prefix,
buf, readlen);
write_or_die(1, buf, readlen);
}
@ -460,7 +463,8 @@ static int write_zip_entry(struct archiver_args *args,
break;
crc = crc32(crc, buf, readlen);
if (is_binary == -1)
is_binary = entry_is_binary(path_without_prefix,
is_binary = entry_is_binary(args->repo->index,
path_without_prefix,
buf, readlen);
zstream.next_in = buf;