summaryrefslogtreecommitdiff
path: root/src/diff_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/diff_driver.c')
-rw-r--r--src/diff_driver.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c
index 8136e0dd9..c3c5f365b 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -233,17 +233,17 @@ static int git_diff_driver_load(
return 0;
}
- /* if you can't read config for repo, just use default driver */
- if (git_repository_config__weakptr(&cfg, repo) < 0) {
- giterr_clear();
- goto done;
- }
-
drv = git__calloc(1, sizeof(git_diff_driver) + namelen + 1);
GITERR_CHECK_ALLOC(drv);
drv->type = DIFF_DRIVER_AUTO;
memcpy(drv->name, driver_name, namelen);
+ /* if you can't read config for repo, just use default driver */
+ if (git_repository_config_snapshot(&cfg, repo) < 0) {
+ giterr_clear();
+ goto done;
+ }
+
if ((error = git_buf_printf(&name, "diff.%s.binary", driver_name)) < 0)
goto done;
@@ -321,6 +321,7 @@ static int git_diff_driver_load(
done:
git_buf_free(&name);
+ git_config_free(cfg);
if (!*out) {
int error2 = git_diff_driver_builtin(out, reg, driver_name);
@@ -396,7 +397,11 @@ void git_diff_driver_update_options(
int git_diff_driver_content_is_binary(
git_diff_driver *driver, const char *content, size_t content_len)
{
- const git_buf search = { (char *)content, 0, min(content_len, 4000) };
+ git_buf search;
+
+ search.ptr = (char *)content;
+ search.size = min(content_len, GIT_FILTER_BYTES_TO_CHECK_NUL);
+ search.asize = 0;
GIT_UNUSED(driver);