Description: Use the system libgit2 library
Author: Thomas Pierson <contact@thomaspierson.fr>
Forwarded: https://github.com/spersson/Kup/pull/46
Last-Update: 2017-03-10

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,5 @@
 cmake_minimum_required(VERSION 3.0)
 
-set(BUILD_SHARED_LIBS ON)
-add_subdirectory(libgit2-0.19.0)
-include_directories(${CMAKE_SOURCE_DIR}/libgit2-0.19.0/include)
 project(kup)
 
 find_package(ECM REQUIRED NO_MODULE)
@@ -24,6 +21,7 @@
 include(ECMInstallIcons)
 
 find_package(Qt5 REQUIRED COMPONENTS Widgets)
+find_package(LibGit2 REQUIRED)
 find_package(KF5 REQUIRED COMPONENTS
 Solid
 KIO
--- a/filedigger/main.cpp
+++ b/filedigger/main.cpp
@@ -21,7 +21,7 @@
 #include "filedigger.h"
 #include "mergedvfs.h"
 
-#include <git2/threads.h>
+#include <git2/global.h>
 
 #include <KAboutData>
 #include <KLocalizedString>
@@ -69,7 +69,7 @@
 	}
 
 	// This needs to be called first thing, before any other calls to libgit2.
-	git_threads_init();
+	git_libgit2_init();
 	MergedRepository *lRepository = new MergedRepository(NULL, lParser.positionalArguments().first(),
 	                                                     lParser.value("branch"));
 	if(!lRepository->open()) {
@@ -93,6 +93,6 @@
 	lFileDigger->show();
 	int lRetVal = lApp.exec();
 	delete lRepository;
-	git_threads_shutdown();
+	git_libgit2_shutdown();
 	return lRetVal;
 }
--- a/filedigger/CMakeLists.txt
+++ b/filedigger/CMakeLists.txt
@@ -25,7 +25,7 @@
 KF5::KIOFileWidgets
 KF5::I18n
 KF5::IconThemes
-git24kup
+git2
 )
 
 ########### install files ###############
--- a/kioslave/CMakeLists.txt
+++ b/kioslave/CMakeLists.txt
@@ -10,7 +10,7 @@
 Qt5::Core
 KF5::KIOCore
 KF5::I18n
-git24kup
+git2
 )
 
 install(TARGETS kio_bup DESTINATION ${PLUGIN_INSTALL_DIR})
--- a/kioslave/bupslave.cpp
+++ b/kioslave/bupslave.cpp
@@ -44,14 +44,14 @@
 {
 	mRepository = NULL;
 	mOpenFile = NULL;
-	git_threads_init();
+	git_libgit2_init();
 }
 
 BupSlave::~BupSlave() {
 	if(mRepository != NULL) {
 		delete mRepository;
 	}
-	git_threads_shutdown();
+	git_libgit2_shutdown();
 }
 
 void BupSlave::close() {
