From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dominique Leuenberger <dimstar@opensuse.org>
Date: Fri, 5 Apr 2024 10:28:16 +0200
Subject: [PATCH] build: Fix build against, and require, libgit2 1.8.0

---
 libgit2-glib/ggit-clone-options.c        | 1 +
 libgit2-glib/ggit-cred-ssh-interactive.c | 2 +-
 libgit2-glib/ggit-remote-callbacks.h     | 1 +
 libgit2-glib/ggit-repository.c           | 4 ++--
 libgit2-glib/ggit-types.h                | 3 ++-
 meson.build                              | 2 +-
 6 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libgit2-glib/ggit-clone-options.c b/libgit2-glib/ggit-clone-options.c
index b47fdb17b3d7..30c7d860d8bc 100644
--- a/libgit2-glib/ggit-clone-options.c
+++ b/libgit2-glib/ggit-clone-options.c
@@ -19,6 +19,7 @@
  */
 
 #include <git2.h>
+#include <git2/sys/errors.h>
 #include <gio/gio.h>
 
 #include "ggit-clone-options.h"
diff --git a/libgit2-glib/ggit-cred-ssh-interactive.c b/libgit2-glib/ggit-cred-ssh-interactive.c
index 4f60f8bd548b..0bdca95f7d60 100644
--- a/libgit2-glib/ggit-cred-ssh-interactive.c
+++ b/libgit2-glib/ggit-cred-ssh-interactive.c
@@ -191,7 +191,7 @@ callback_wrapper (const char                            *name,
 	{
 		gchar *text;
 
-		text = g_strndup (prompts[i].text, prompts[i].length);
+		text = g_strndup ((const gchar *)prompts[i].text, prompts[i].length);
 
 		wprompts[i] = ggit_cred_ssh_interactive_prompt_new (wname,
 		                                                    winstruction,
diff --git a/libgit2-glib/ggit-remote-callbacks.h b/libgit2-glib/ggit-remote-callbacks.h
index 3005ff4c4966..2340712a7ba3 100644
--- a/libgit2-glib/ggit-remote-callbacks.h
+++ b/libgit2-glib/ggit-remote-callbacks.h
@@ -24,6 +24,7 @@
 
 #include <glib-object.h>
 #include <git2.h>
+#include <git2/sys/errors.h>
 #include <libgit2-glib/ggit-cred.h>
 
 G_BEGIN_DECLS
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index bf099f6c8a9a..936c6fcff79f 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -3182,7 +3182,7 @@ ggit_repository_create_commit (GgitRepository  *repository,
 	                         message,
 	                         _ggit_native_get (tree),
 	                         parent_count,
-	                         (const git_commit **)parents_native);
+	                         (gpointer)parents_native);
 
 	g_free (parents_native);
 
@@ -3323,7 +3323,7 @@ ggit_repository_create_commit_buffer(GgitRepository *repository,
 	                                message,
 	                                _ggit_tree_get_tree (tree),
 	                                parent_count,
-	                                (git_commit const **)parents_native);
+	                                (gpointer)parents_native);
 
 	g_free (parents_native);
 
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 7e28975b3d96..2a2ed99e5511 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -355,7 +355,8 @@ typedef enum
 	GGIT_CONFIG_LEVEL_XDG         = 3,
 	GGIT_CONFIG_LEVEL_GLOBAL      = 4,
 	GGIT_CONFIG_LEVEL_LOCAL       = 5,
-	GGIT_CONFIG_LEVEL_APP         = 6,
+	GGIT_CONFIG_LEVEL_WORKTREE    = 6,
+	GGIT_CONFIG_LEVEL_APP         = 7,
 	GGIT_CONFIG_LEVEL_HIGHEST     = -1
 } GgitConfigLevel;
 
diff --git a/meson.build b/meson.build
index e54a8b431d7b..c21107d5cab5 100644
--- a/meson.build
+++ b/meson.build
@@ -126,7 +126,7 @@ glib_dep = dependency('glib-2.0', version: '>=' + glib_req)
 gobject_dep = dependency('gobject-2.0', version: '>=' + glib_req)
 gio_dep = dependency('gio-2.0', version: '>=' + glib_req)
 
-libgit2_dep = dependency('libgit2', version: '>= 0.25.0')
+libgit2_dep = dependency('libgit2', version: '>= 1.8.0')
 
 # XXX: Not nice, but probably our best option
 enable_gir = get_option('introspection') and find_program('g-ir-scanner', required: false).found()
