From f53bf4991eaa87600654949f8a6014cee31e5187 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 5 May 2019 18:47:01 +0200 Subject: [PATCH] Fixed crash in newest libgit2: initialize must now be called before using git_diff_buffers --- src/git.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/git.cc b/src/git.cc index d2ae2c0..5a157f7 100644 --- a/src/git.cc +++ b/src/git.cc @@ -59,11 +59,13 @@ Git::Repository::Diff::Lines Git::Repository::Diff::get_lines(const std::string } std::vector Git::Repository::Diff::get_hunks(const std::string &old_buffer, const std::string &new_buffer) { + initialize(); std::vector hunks; Error error; git_diff_options options; git_diff_init_options(&options, GIT_DIFF_OPTIONS_VERSION); options.context_lines = 0; + std::lock_guard lock(mutex); error.code = git_diff_buffers(old_buffer.c_str(), old_buffer.size(), nullptr, new_buffer.c_str(), new_buffer.size(), nullptr, &options, nullptr, nullptr, [](const git_diff_delta *delta, const git_diff_hunk *hunk, void *payload) { auto hunks = static_cast *>(payload); hunks->emplace_back(hunk->old_start, hunk->old_lines, hunk->new_start, hunk->new_lines);