Introduction

Recently libgit2 released version 0.28 which had a few changes to the API, most prominently the change of giterr functions to git_error and the rename of git_buf_free to git_buf_dispose.

This isn't much of a problem, those changes were wonderfully explained in the release notes.

So i sprang into action, all of it sounded easy, turns out thanks to a specific fearlessly concurrent language and its ecosystem, it wasn't.

Updating libgit2

But first things first, let's update libgit2, should be easy enough right.

commit ce23069f09af4075c458f5fd680e075218ad8131
Author: maxice8 <thinkabit.ukim@gmail.com>
Date:   Mon Feb 11 22:12:40 2019 -0200

    libgit2: update to 0.28.0.

diff --git a/common/shlibs b/common/shlibs
index 01135ae5a3..0a46502041 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1286,7 +1286,7 @@ libunwind-aarch64.so.8 libunwind-1.2rc1_1
 libunwind-ppc32.so.8 libunwind-1.2.1_1
 libunwind-ppc64.so.8 libunwind-1.2.1_1
 libmicrohttpd.so.12 libmicrohttpd-0.9.48_1
-libgit2.so.27 libgit2-0.27.3_1
+libgit2.so.28 libgit2-0.28.0_1
 libgit2-glib-1.0.so.0 libgit2-glib-0.23.4_1
 libagg.so.2 agg-2.5_1
 libzzip-0.so.13 zziplib-0.13.62_1
diff --git a/srcpkgs/libgit2/template b/srcpkgs/libgit2/template
index c12d2a0e20..5de00bef29 100644
--- a/srcpkgs/libgit2/template
+++ b/srcpkgs/libgit2/template
@@ -1,6 +1,6 @@
 # Template file for 'libgit2'
 pkgname=libgit2
-version=0.27.8
+version=0.28.0
 revision=1
 build_style=cmake
 configure_args="-DTHREADSAFE=ON"
@@ -11,7 +11,7 @@ maintainer="Juan RP <xtraeme@voidlinux.org>"
 license="GPL-2.0-or-later WITH GCC-exception-2.0"
 homepage="https://libgit2.org"
 distfiles="https://github.com/libgit2/libgit2/archive/v${version}.tar.gz"
-checksum=8313873d49dc01e8b880ec334d7430ae67496a89aaa8c6e7bbd3affb47a00c76
+checksum=9d60d64dc77085e8e530e5c66314057eafe0c06e4a7a61149a70ff3e0688f284
 
 case "$XBPS_TARGET_MACHINE" in
    *-musl)

Literally just that, we update to the new version and now the fun starts. Since we updated the entry in common/shlibs that means it has a new soname which requires us to rebuild every package that depends on libgit2.so.27 to now depend on libgit2.so.28

Updating dependencies

To get those packages we grab another tool from the excelent xtools toolbox the xrevshlib script. Which parses the shlib-provides and shlib-requires fields from packages to get which packages shlib-requires libgit2.so.28.

Let's put it into action.

$ xrevshlib libgit2
Fritzing
amp
calligra
cargo
cargo-outdated
geany-plugins
git-series
grv
juCi++
ktexteditor
libgit2-glib
slcp
stagit

Hey that was easier than i thought, those are all the packages that we need to revbump, Let's bring out another tool xrevbump to help us.

$ xrevshlib libgit2 \
| xargs env IGNORE_XLINT=1 NO_FORMALIZE=1 xrevbump 'rebuild against libgit2.so.28

[ci skip]'

This will revbump every package with the commit meessage:

rebuild against libgit2.so.28

[ci skip]

The [ci skip] is a Travis CI construct that allows us to skip Travis CI trying to compile this package, since we are revbumping quite a few packages we will break the 50 minutes limit we have on it.

The IGNORE_XLINT and NO_FORMALIZE are specific variables to my workflow, if you wish to know more about them let me know, just be aware you don't actually need them when doing this yourself.

Let's take a look at the git log of changes:

7bfe97313e stagit: rebuild against libgit2.so.28
219e4b5954 slcp: rebuild against libgit2.so.28
a52dab1a50 libgit2-glib: rebuild against libgit2.so.28
fad5b11174 ktexteditor: rebuild against libgit2.so.28
8f462f2d16 juCi++: rebuild against libgit2.so.28
d6b6ebb2da grv: rebuild against libgit2.so.28
1fc58c17e1 git-series: rebuild against libgit2.so.28
05502f194b geany-plugins: rebuild against libgit2.so.28
82b874208a cargo-outdated: rebuild against libgit2.so.28
c6964e1eb7 cargo: rebuild against libgit2.so.28
ad513ee86c calligra: rebuild against libgit2.so.28
6c09605ffa amp: rebuild against libgit2.so.28
3bdfbb90bb Fritzing: rebuild against libgit2.so.28
ce23069f09 libgit2: update to 0.28.0.

Seems fine to me, let's start building them.

stagit

Seems the simplest:

$ xbps-src pkg stagit
=> stagit-0.9_2: running do_build ...
cc -c -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe    -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE -I/usr/local/include -o stagit.o -c stagit.c
cc -c -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe    -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE -I/usr/local/include -o reallocarray.o -c reallocarray.c
cc -c -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe    -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE -I/usr/local/include -o strlcat.o -c strlcat.c
cc -c -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe    -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE -I/usr/local/include -o strlcpy.o -c strlcpy.c
cc -o stagit stagit.o reallocarray.o strlcat.o strlcpy.o -Wl,-z,relro -Wl,-z,now -Wl,--as-needed    -lgit2
/usr/bin/ld: stagit.o: in function `main':
stagit.c:(.text.startup+0x84d): undefined reference to `giterr_last'
collect2: error: ld returned 1 exit status
make: *** [Makefile:53: stagit] Error 1

Oh, no problem, we know that giterr_ functions were renamed to git_error

diff --git a/stagit-index.c b/stagit-index.c
index e019793..6b25969 100644
--- stagit-index.c
+++ stagit-index.c
@@ -174,7 +174,7 @@ main(int argc, char *argv[])
 
        if (git_repository_open_ext(&repo, repodir,
            GIT_REPOSITORY_OPEN_NO_SEARCH, NULL)) {
-			e = giterr_last();
+			e = git_error_last();
            fprintf(stderr, "%s: %s\n", argv[0], e->message);
            ret = 1;
            continue;
diff --git a/stagit.c b/stagit.c
index 093cdab..25be042 100644
--- stagit.c
+++ stagit.c
@@ -1101,7 +1101,7 @@ main(int argc, char *argv[])
 
    if (git_repository_open_ext(&repo, repodir,
        GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) < 0) {
-		e = giterr_last();
+		e = git_error_last();
        fprintf(stderr, "%s: %s\n", argv[0], e->message);
        return 1;
    }

And again

$ xbps-src pkg stagit
=> Registering new packages to /host/binpkgs/libgit2
index: added `stagit-0.9_2' (x86_64).
index: 26 packages registered.

Sadly the project uses only Mailing Lists which i particularly don't like, i use it (like iwd) but if given a choice i'd rather not.

slcp

Seems like another small project that can be quickly done:

$ xbps-src 
CC -o slcp
/usr/bin/ld: slcp.o: in function `main':
/builddir/slcp-0.2/slcp.c:109: undefined reference to `git_buf_free'
collect2: error: ld returned 1 exit status
make: *** [Makefile:29: slcp] Error 1

Oh, an error, but thanks to libgit2's changelog we know that git_buf_free became git_buf_dispose.

diff --git a/slcp.c b/slcp.c
index 7f12b08..e93c1fd 100644
--- slcp.c
+++ slcp.c
@@ -106,7 +106,7 @@ int main(int argc, char* argv[])
    {
        git_repo = NULL;
    }
-	git_buf_free(&tmpgitdb);
+	git_buf_dispose(&tmpgitdb);
 
    /* prepare some git information */
    if(git_repo) {

And now ?

$ xbps-src pkg slcp
=> Registering new packages to /host/binpkgs/libgit2
index: added `slcp-0.2_11' (x86_64).
index: 26 packages registered.

I filled a pull request upstream the fix should be available in the next release.

Fritzing

Oh, quite a bigger project but, hey:

$ xbps-src pkg Fritzing
=> Registering new packages to /host/binpkgs/libgit2
index: added `Fritzing-0.9.3b_4' (x86_64).
index: 26 packages registered.

Haha, first try!

juCi++

$ xbps-src pkg juCi++
[100%] Linking CXX executable juci
/usr/bin/ld: libjuci_shared.a(git.cc.o): in function `Git::Error::message[abi:cxx11]()':
git.cc:(.text+0x902): undefined reference to `giterr_last'
/usr/bin/ld: libjuci_shared.a(git.cc.o): in function `Git::Repository::get_root_path(boost::filesystem::path const&)':
git.cc:(.text+0x22d5): undefined reference to `git_buf_free'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/juci.dir/build.make:258: src/juci] Error 1
make[1]: *** [CMakeFiles/Makefile2:223: src/CMakeFiles/juci.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
=> ERROR: juCi++-1.4.6_4: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/cmake.sh:71

Typical, giterr usage and git_buf_free, the fixes should be easy.

diff --git a/src/git.cc b/src/git.cc
index 9da2d7b..45e9007 100644
--- src/git.cc
+++ src/git.cc
@@ -6,7 +6,7 @@ bool Git::initialized = false;
 std::mutex Git::mutex;
 
 std::string Git::Error::message() noexcept {
-  const git_error *last_error = giterr_last();
+  const git_error *last_error = git_error_last();
   if(last_error == nullptr)
     return std::string();
   else
@@ -244,7 +244,7 @@ boost::filesystem::path Git::Repository::get_root_path(const boost::filesystem::
       throw std::runtime_error(error.message());
   }
   auto root_path = Git::path(root.ptr, root.size);
-  git_buf_free(&root);
+  git_buf_dispose(&root);
   return root_path;
 }

Ok, with those fixed, what do we do ?

$ xbps-src pkg juCi++
=> Registering new packages to /host/binpkgs/libgit2
index: added `juCi++-1.4.6_4' (x86_64).
index: 26 packages registered.

A merge request was filled against upstream.

They asked for wrapping in pre-processor so it works against both pre-0.28 and the 0.28 API so it is done. The final version can be seen in the merge request.

ktexteditor

$ xbps-src pkg ktexteditor
=> Registering new packages to /host/binpkgs/libgit2
index: added `ktexteditor-5.55.0_2' (x86_64).
index: 26 packages registered.

Nice, just like Fritzing.

libgit2-glib

This one is particularly important as is very used in GNOME.

$ xbps-src pkg libgit2-glib
/usr/bin/ld: /tmp/ccR9BQNN.ltrans0.ltrans.o: in function `ggit_patch_to_string':
<artificial>:(.text+0x323b): undefined reference to `git_buf_free'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans0.ltrans.o: in function `credentials_wrap':
<artificial>:(.text+0x3da3): undefined reference to `giterr_set_str'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans0.ltrans.o: in function `ggit_message_prettify':
<artificial>:(.text+0x584a): undefined reference to `git_buf_free'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans0.ltrans.o: in function `_ggit_error_set':
<artificial>:(.text+0x6702): undefined reference to `giterr_last'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans0.ltrans.o: in function `ggit_repository_get_default_notes_ref':
<artificial>:(.text+0x75c1): undefined reference to `git_buf_free'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans0.ltrans.o: in function `ggit_repository_discover_full':
<artificial>:(.text+0x8ea0): undefined reference to `git_buf_free'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans1.ltrans.o: in function `ggit_config_find_system':
<artificial>:(.text+0x3138): undefined reference to `git_buf_free'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans1.ltrans.o: in function `ggit_config_find_global':
<artificial>:(.text+0x31a8): undefined reference to `git_buf_free'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans1.ltrans.o: in function `ggit_diff_format_email':
<artificial>:(.text+0x5f07): undefined reference to `git_buf_free'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans1.ltrans.o:<artificial>:(.text+0x5f3a): more undefined references to `git_buf_free' follow
/usr/bin/ld: /tmp/ccR9BQNN.ltrans1.ltrans.o: in function `create_repository_wrapper':
<artificial>:(.text+0x80c0): undefined reference to `giterr_set_str'
/usr/bin/ld: /tmp/ccR9BQNN.ltrans1.ltrans.o: in function `create_remote_wrapper':
<artificial>:(.text+0x819f): undefined reference to `giterr_set_str'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
=> ERROR: libgit2-glib-0.27.7_2: do_build: '${make_cmd} -C ${meson_builddir} ${makejobs} ${make_build_args} ${make_build_target}' exited with 1
=> ERROR:   in do_build() at common/build-style/meson.sh:126

Oh wow, lots of errors, but all of them either giterr or git_buf_free. Should be trivial by now, let's fix them.

diff --git a/libgit2-glib/ggit-clone-options.c b/libgit2-glib/ggit-clone-options.c
index 1288a82..9234efc 100644
--- libgit2-glib/ggit-clone-options.c
+++ libgit2-glib/ggit-clone-options.c
@@ -149,7 +149,7 @@ create_repository_wrapper (git_repository **out,
 
    if (error != NULL)
    {
-		giterr_set_str (GIT_ERROR, error->message);
+		git_error_set_str (GIT_ERROR, error->message);
        g_error_free (error);
 
        if (repository != NULL)
@@ -187,7 +187,7 @@ create_remote_wrapper (git_remote     **out,
 
    if (error)
    {
-		giterr_set_str (GIT_ERROR, error->message);
+		git_error_set_str (GIT_ERROR, error->message);
        g_error_free (error);
 
        if (remote != NULL)
diff --git a/libgit2-glib/ggit-config.c b/libgit2-glib/ggit-config.c
index acdad95..84601de 100644
--- libgit2-glib/ggit-config.c
+++ libgit2-glib/ggit-config.c
@@ -191,7 +191,7 @@ ggit_config_find_global (void)
    if (git_config_find_global (&buf) == GIT_OK)
    {
        path = g_file_new_for_path (buf.ptr);
-		git_buf_free (&buf);
+		git_buf_dispose (&buf);
    }
 
    return path;
@@ -220,7 +220,7 @@ ggit_config_find_system (void)
    if (git_config_find_system (&buf) == GIT_OK)
    {
        path = g_file_new_for_path (buf.ptr);
-		git_buf_free (&buf);
+		git_buf_dispose (&buf);
    }
 
    return path;
diff --git a/libgit2-glib/ggit-diff.c b/libgit2-glib/ggit-diff.c
index db9361d..1d62328 100644
--- libgit2-glib/ggit-diff.c
+++ libgit2-glib/ggit-diff.c
@@ -786,13 +786,13 @@ ggit_diff_format_email (GgitDiff                    *diff,
 
    if (ret != GIT_OK)
    {
-		git_buf_free (&buf);
+		git_buf_dispose (&buf);
        _ggit_error_set (error, ret);
        return NULL;
    }
 
    retval = g_strndup (buf.ptr, buf.size);
-	git_buf_free (&buf);
+	git_buf_dispose (&buf);
 
    return retval;
 }
diff --git a/libgit2-glib/ggit-error.c b/libgit2-glib/ggit-error.c
index 06a21a7..acc1eb2 100644
--- libgit2-glib/ggit-error.c
+++ libgit2-glib/ggit-error.c
@@ -51,7 +51,7 @@ _ggit_error_set (GError **error,
    g_return_if_fail (err < 0);
 
    /* TODO: add more kind of errors, see git_error_t */
-	git2_err = giterr_last ();
+	git2_err = git_error_last ();
    g_set_error_literal (error, GGIT_ERROR,
                         err,
                         git2_err == NULL ? "" : git2_err->message);
diff --git a/libgit2-glib/ggit-message.c b/libgit2-glib/ggit-message.c
index 0fa9e8c..5100e52 100644
--- libgit2-glib/ggit-message.c
+++ libgit2-glib/ggit-message.c
@@ -46,7 +46,7 @@ ggit_message_prettify (const gchar *message,
    git_message_prettify (&buf, message, strip_comments, comment_char);
 
    d = g_strdup (buf.ptr);
-	git_buf_free (&buf);
+	git_buf_dispose (&buf);
 
    return d;
 }
diff --git a/libgit2-glib/ggit-patch.c b/libgit2-glib/ggit-patch.c
index ee04e4d..eff9e84 100644
--- libgit2-glib/ggit-patch.c
+++ libgit2-glib/ggit-patch.c
@@ -194,7 +194,7 @@ ggit_patch_to_string (GgitPatch  *patch,
    if (ret == GIT_OK)
    {
        result = g_strdup (buf.ptr);
-		git_buf_free (&buf);
+		git_buf_dispose (&buf);
    }
 
    return result;
diff --git a/libgit2-glib/ggit-remote-callbacks.c b/libgit2-glib/ggit-remote-callbacks.c
index a4bc130..03064eb 100644
--- libgit2-glib/ggit-remote-callbacks.c
+++ libgit2-glib/ggit-remote-callbacks.c
@@ -160,7 +160,7 @@ credentials_wrap (git_cred     **cred,
        {
            if (error)
            {
-				giterr_set_str (GIT_ERROR, error->message);
+				git_error_set_str (GIT_ERROR, error->message);
                g_error_free (error);
 
                return GIT_ERROR;
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index b9bd2b7..40e06df 100644
--- libgit2-glib/ggit-repository.c
+++ libgit2-glib/ggit-repository.c
@@ -1013,7 +1013,7 @@ ggit_repository_discover_full (GFile        *location,
    if (ret == GIT_OK)
    {
        rep = g_file_new_for_path (buf.ptr);
-		git_buf_free (&buf);
+		git_buf_dispose (&buf);
    }
    else
    {
@@ -3680,7 +3680,7 @@ ggit_repository_get_default_notes_ref (GgitRepository  *repository,
    }
 
    ref = g_strdup (buf.ptr);
-	git_buf_free (&buf);
+	git_buf_dispose (&buf);
 
    return ref;
 }

Quite a long patch.

$ xbps-src pkg libgit2-glib
=> Registering new packages to /host/binpkgs/libgit2
index: added `libgit2-glib-0.27.7_2' (x86_64).
index: 26 packages registered.

Nice, a merge request has been filled against upstream.

geany-plugins

$ xbps-src pkg geany-plugins
/usr/bin/ld: .libs/git_changebar_la-gcb-plugin.o: in function `clear_cached_blob_contents':
gcb-plugin.c:(.text+0x76): undefined reference to `git_buf_free'
/usr/bin/ld: .libs/git_changebar_la-gcb-plugin.o: in function `free_job':
gcb-plugin.c:(.text+0x170): undefined reference to `git_buf_free'
/usr/bin/ld: .libs/git_changebar_la-gcb-plugin.o: in function `worker_thread':
gcb-plugin.c:(.text+0xf7b): undefined reference to `git_buf_free'
/usr/bin/ld: .libs/git_changebar_la-gcb-plugin.o: in function `plugin_init':
gcb-plugin.c:(.text+0x2559): undefined reference to `giterr_last'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:609: git-changebar.la] Error 1
make[3]: Leaving directory '/builddir/geany-plugins-1.34.0/git-changebar/src'
make[2]: *** [Makefile:584: all-recursive] Error 1
make[2]: Leaving directory '/builddir/geany-plugins-1.34.0/git-changebar'
make[1]: *** [Makefile:630: all-recursive] Error 1
make[1]: Leaving directory '/builddir/geany-plugins-1.34.0'
make: *** [Makefile:562: all] Error 2
=> ERROR: geany-plugins-1.34.0_2: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:13

As is pattern, let's fix it.

diff --git a/git-changebar/src/gcb-plugin.c b/git-changebar/src/gcb-plugin.c
index 532a99a..886aa9f 100644
--- git-changebar/src/gcb-plugin.c
+++ git-changebar/src/gcb-plugin.c
@@ -238,7 +238,7 @@ static void
 clear_cached_blob_contents (void)
 {
   if (G_blob_contents.ptr) {
-    git_buf_free (&G_blob_contents);
+    git_buf_dispose (&G_blob_contents);
     buf_zero (&G_blob_contents);
   }
   G_blob_contents_tag = 0;
@@ -293,7 +293,7 @@ free_job (gpointer data)
   
   /* unlikely, but if we still have the buffer, free it */
   if (job->buf.ptr) {
-    git_buf_free (&job->buf);
+    git_buf_dispose (&job->buf);
   }
   g_free (job->path);
   g_slice_free1 (sizeof *job, job);
@@ -463,7 +463,7 @@ worker_thread (gpointer data)
       
       if (relpath) {
         if (! repo_get_file_blob_contents (repo, relpath, &job->buf, 0)) {
-          git_buf_free (&job->buf);
+          git_buf_dispose (&job->buf);
           buf_zero (&job->buf);
         }
         
@@ -1481,7 +1481,7 @@ plugin_init (GeanyData *data)
   G_queue             = NULL;
   
   if (git_libgit2_init () < 0) {
-    const git_error *err = giterr_last ();
+    const git_error *err = git_error_last ();
     g_warning ("Failed to initialize libgit2: %s", err ? err->message : "?");
     return;
   }

With those fixes, let's see if it fixed.

$ xbps-src pkg geany-plugins
=> Registering new packages to /host/binpkgs/libgit2
index: added `geany-plugins-1.34.0_2' (x86_64).
index: 26 packages registered.

A pull request has been made. It has been asked to wrap them around so they can be compiled against both old and new API, so do it like juCi++

Calligra

This is a big one

$ xbps-src pkg calligra
[ 49%] Linking CXX shared library libcalligrageminigitplugin.so
/usr/bin/ld: CMakeFiles/calligrageminigitplugin.dir/gitcontroller.cpp.o: in function `GitOpsThread::performPush()':
gitcontroller.cpp:(.text+0x103b): undefined reference to `git_buf_free'
/usr/bin/ld: gitcontroller.cpp:(.text+0x1319): undefined reference to `giterr_last'
/usr/bin/ld: gitcontroller.cpp:(.text+0x1523): undefined reference to `giterr_last'
/usr/bin/ld: gitcontroller.cpp:(.text+0x1669): undefined reference to `giterr_last'
/usr/bin/ld: gitcontroller.cpp:(.text+0x16c1): undefined reference to `giterr_last'
/usr/bin/ld: gitcontroller.cpp:(.text+0x18ad): undefined reference to `giterr_last'
/usr/bin/ld: CMakeFiles/calligrageminigitplugin.dir/gitcontroller.cpp.o:gitcontroller.cpp:(.text+0x19e1): more undefined references to `giterr_last' follow
/usr/bin/ld: CMakeFiles/calligrageminigitplugin.dir/gitcontroller.cpp.o: in function `GitOpsThread::performPull()':
gitcontroller.cpp:(.text+0x24f0): undefined reference to `git_buf_free'
/usr/bin/ld: gitcontroller.cpp:(.text+0x2709): undefined reference to `giterr_last'
/usr/bin/ld: gitcontroller.cpp:(.text+0x29d1): undefined reference to `giterr_last'
/usr/bin/ld: gitcontroller.cpp:(.text+0x2ab5): undefined reference to `giterr_last'
/usr/bin/ld: gitcontroller.cpp:(.text+0x2b91): undefined reference to `giterr_last'
/usr/bin/ld: gitcontroller.cpp:(.text+0x2ca1): undefined reference to `giterr_last'
/usr/bin/ld: CMakeFiles/calligrageminigitplugin.dir/gitcontroller.cpp.o:gitcontroller.cpp:(.text+0x2e99): more undefined references to `giterr_last' follow
collect2: error: ld returned 1 exit status
make[2]: *** [gemini/cloud/git/CMakeFiles/calligrageminigitplugin.dir/build.make:165: gemini/cloud/git/libcalligrageminigitplugin.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:6387: gemini/cloud/git/CMakeFiles/calligrageminigitplugin.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
=> ERROR: calligra-3.1.0_17: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/cmake.sh:71

Familiar errors, let fix them:

diff --git a/gemini/cloud/git/checkoutcreator.cpp b/gemini/cloud/git/checkoutcreator.cpp
index b6004b1..42e038e 100644
--- gemini/cloud/git/checkoutcreator.cpp
+++ gemini/cloud/git/checkoutcreator.cpp
@@ -243,7 +243,7 @@ QString CheckoutCreator::createClone(QString userVisibleName, QString url, QStri
 
     git_repository *repo = NULL;
     int error = git_clone(&repo, url.toLatin1(), checkoutLocation.toLatin1(), &clone_opts);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return QString(); }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return QString(); }
 
     return checkoutLocation;
 }
diff --git a/gemini/cloud/git/gitcontroller.cpp b/gemini/cloud/git/gitcontroller.cpp
index 9bbf058..8fc6984 100644
--- gemini/cloud/git/gitcontroller.cpp
+++ gemini/cloud/git/gitcontroller.cpp
@@ -168,75 +168,75 @@ void GitOpsThread::performPush()
 {
     git_repository* repository;
     int error = git_repository_open(&repository, QString("%1/.git").arg(d->gitDir).toLatin1());
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 1, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 1, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // Get the current index
     git_index* index;
     error = git_repository_index(&index, repository);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 2, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 2, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // refresh it, and add the file
     error = git_index_read(index, true);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 3, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 3, error code from git2 was" << error << "which is described as" << err->message; return; }
 #ifdef Q_OS_WIN
     QString relative = d->currentFile.mid(d->gitDir.length() + 9); // That is, 1 for the leading slash, and 8 for the file:///
 #else
     QString relative = d->currentFile.mid(d->gitDir.length() + 8); // That is, 1 for the leading slash, and 8 for the file://
 #endif
     error = git_index_add_bypath(index, relative.toLocal8Bit());
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 4, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 4, error code from git2 was" << error << "which is described as" << err->message; return; }
     error = git_index_write(index);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 5, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 5, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // convert the index to a tree, so we can use that to create the commit
     git_tree* tree;
     git_oid tree_id;
     error = git_index_write_tree(&tree_id, index);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 6, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 6, error code from git2 was" << error << "which is described as" << err->message; return; }
     error = git_tree_lookup(&tree, repository, &tree_id);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 7, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 7, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // get where we want to parent things to
     git_oid obj;
     error = git_reference_name_to_id(&obj, repository, "HEAD");
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 8, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 8, error code from git2 was" << error << "which is described as" << err->message; return; }
     git_commit *parent = NULL;
     error = git_commit_lookup(&parent, repository, &obj);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 9, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 9, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // create the commit
     git_oid oid;
     error = git_commit_create_v(&oid, repository, "HEAD", d->signature, d->signature, "UTF-8", d->message.toLatin1(), tree, 1, parent);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 10, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 10, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     error = git_repository_state_cleanup(repository);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 11, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 11, error code from git2 was" << error << "which is described as" << err->message; return; }
 
 
     // Find the current branch's upstream remote
     git_reference *current_branch;
     error = git_repository_head(&current_branch, repository);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 12, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 12, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     git_reference *upstream;
     error = git_branch_upstream(&upstream, current_branch);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 13, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 13, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // Now find the name of the remote
     git_buf remote_name = {0,0,0};
     error = git_branch_remote_name(&remote_name, repository, git_reference_name(upstream));
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 14, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 14, error code from git2 was" << error << "which is described as" << err->message; return; }
     QString remoteName = QString::fromUtf8(remote_name.ptr);
-    git_buf_free(&remote_name);
+    git_buf_dispose(&remote_name);
 
     // And the upstream and local branch names...
     const char *branch_name;
     error = git_branch_name(&branch_name, upstream);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 15, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 15, error code from git2 was" << error << "which is described as" << err->message; return; }
     QString upstreamBranchName = QString::fromUtf8(branch_name);
     upstreamBranchName.remove(0, remoteName.length() + 1);
     error = git_branch_name(&branch_name, current_branch);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 16, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 16, error code from git2 was" << error << "which is described as" << err->message; return; }
     QString branchName = QString::fromUtf8(branch_name);
 
     git_remote_callbacks remoteCallbacks = GIT_REMOTE_CALLBACKS_INIT;
@@ -245,7 +245,7 @@ void GitOpsThread::performPush()
     remoteCallbacks.credentials = &Private::acquireCredentialsCallback;
     git_remote* remote;
     error = git_remote_lookup(&remote, repository, "origin");
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 17, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 17, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     char tempPath[512] = "refs/heads/";
     char tempPath2[512] = "refs/heads/";
@@ -258,11 +258,11 @@ void GitOpsThread::performPush()
 
     git_push_options pushOptions;
     error = git_push_init_options(&pushOptions, GIT_PUSH_OPTIONS_VERSION);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 18, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 18, error code from git2 was" << error << "which is described as" << err->message; return; }
     pushOptions.callbacks = remoteCallbacks;
 
     error = git_remote_push(remote, &uploadrefs, &pushOptions);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 19, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 19, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     emit pushCompleted();
 }
@@ -271,21 +271,21 @@ void GitOpsThread::performPull()
 {
     git_repository* repository;
     int error = git_repository_open(&repository, QString("%1/.git").arg(d->gitDir).toLatin1());
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // Find the current branch's upstream remote
     git_reference *current_branch;
     error = git_repository_head(&current_branch, repository);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     git_reference *upstream;
     error = git_branch_upstream(&upstream, current_branch);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // Now find the name of the remote
     git_buf remote_name = {0,0,0};
     error = git_branch_remote_name(&remote_name, repository, git_reference_name(upstream));
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // Finally set the credentials on it that we're given, and fetch it
     git_remote_callbacks remoteCallbacks = GIT_REMOTE_CALLBACKS_INIT;
@@ -294,15 +294,15 @@ void GitOpsThread::performPull()
     remoteCallbacks.credentials = &Private::acquireCredentialsCallback;
     git_remote* remote;
     error = git_remote_lookup(&remote, repository, remote_name.ptr);
-    git_buf_free(&remote_name);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    git_buf_dispose(&remote_name);
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
     git_fetch_options fetch_options = GIT_FETCH_OPTIONS_INIT;
     fetch_options.callbacks = remoteCallbacks;
     error = git_remote_fetch(remote, NULL, &fetch_options, NULL);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     error = git_branch_upstream(&upstream, current_branch);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     // Let's check and see what sort of merge we should be doing...
     git_merge_analysis_t analysis;
@@ -480,19 +480,19 @@ public:
     {
         git_config* configActual;
         int error = git_config_open_default(&configActual);
-        if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
+        if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
 
         git_config* config;
         error = git_config_snapshot(&config, configActual);
-        if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
+        if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
 
         const char* name;
         error = git_config_get_string(&name, config, "user.name");
-        if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
+        if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
 
         const char* email;
         error = git_config_get_string(&email, config, "user.email");
-        if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
+        if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
 
         userName = QString::fromLocal8Bit(name);
         userEmail = QString::fromLocal8Bit(email);
@@ -512,7 +512,7 @@ public:
             }
             userName = newName;
             error = git_config_set_string(config, "user.name", newName.toLocal8Bit());
-            if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
+            if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
         }
         if(userEmail.isEmpty()) {
             bool ok;
@@ -529,7 +529,7 @@ public:
             }
             userEmail = newEmail;
             error = git_config_set_string(config, "user.email", newEmail.toLocal8Bit());
-            if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
+            if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
         }
 
         git_config_free(config);
@@ -538,7 +538,7 @@ public:
             return false;
         }
         error = git_signature_now(&signature, userName.toLocal8Bit(), userEmail.toLocal8Bit());
-        if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
+        if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; }
         return true;
     }
 
diff --git a/gemini/cloud/git/gitlogmodel.cpp b/gemini/cloud/git/gitlogmodel.cpp
index 7496519..d29c91c 100644
--- gemini/cloud/git/gitlogmodel.cpp
+++ gemini/cloud/git/gitlogmodel.cpp
@@ -134,19 +134,19 @@ void GitLogModel::refreshLog()
 
     git_repository* repository;
     int error = git_repository_open(&repository, QString("%1/.git").arg(d->repoDir).toLatin1());
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     git_revwalk *walker;
     error = git_revwalk_new(&walker, repository);
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
     error = git_revwalk_push_range(walker, "HEAD~100..HEAD");
-    if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+    if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
     git_oid oid;
     git_commit *commit = NULL;
     while (git_revwalk_next(&oid, walker) == 0) {
         error = git_commit_lookup(&commit, repository, &oid);
-        if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
+        if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; }
 
         const git_signature *author = git_commit_author(commit);
 

And let's see how it fares:

$ xbps-src pkg calligra
=> Registering new packages to /host/binpkgs/libgit2
index: added `calligra-3.1.0_17' (x86_64).
index: 26 packages registered.

Sadly the contributing process looks convoluted and confusing so i decided to not bother.

Cargo

This one is a deal-breaker and shows particular annoyance of cargo fetch everything model.

$ xbps-src pkg cargo
  = note: /usr/bin/ld: /builddir/cargo-0.33.0/target/release/deps/libgit2-197c7c3d8bde32da.rlib(git2-197c7c3d8bde32da.git2.dj0qflu2-cgu.11.rcgu.o): in function `core::ptr::real_drop_in_place':
          git2.dj0qflu2-cgu.11:(.text._ZN4core3ptr18real_drop_in_place17h1a0b7585d37073a2E+0x2): undefined reference to `git_buf_free'
          /usr/bin/ld: /builddir/cargo-0.33.0/target/release/deps/libgit2-197c7c3d8bde32da.rlib(git2-197c7c3d8bde32da.git2.dj0qflu2-cgu.11.rcgu.o): in function `git2::config::Config::get_string':
          git2.dj0qflu2-cgu.11:(.text._ZN4git26config6Config10get_string17hdef639ea18a87d57E+0x3f0): undefined reference to `git_buf_free'
          /usr/bin/ld: /builddir/cargo-0.33.0/target/release/deps/libgit2-197c7c3d8bde32da.rlib(git2-197c7c3d8bde32da.git2.dj0qflu2-cgu.13.rcgu.o): in function `git2::error::Error::last_error':
          git2.dj0qflu2-cgu.13:(.text._ZN4git25error5Error10last_error17h891df9bd8107df8cE+0x25): undefined reference to `giterr_last'
          /usr/bin/ld: git2.dj0qflu2-cgu.13:(.text._ZN4git25error5Error10last_error17h891df9bd8107df8cE+0x9d): undefined reference to `giterr_last'
          /usr/bin/ld: git2.dj0qflu2-cgu.13:(.text._ZN4git25error5Error10last_error17h891df9bd8107df8cE+0xfd): undefined reference to `giterr_clear'
          /usr/bin/ld: /builddir/cargo-0.33.0/target/release/deps/libgit2-197c7c3d8bde32da.rlib(git2-197c7c3d8bde32da.git2.dj0qflu2-cgu.2.rcgu.o): in function `git2::panic::wrap':
          git2.dj0qflu2-cgu.2:(.text._ZN4git25panic4wrap17h118b1314f6de05f0E+0x2f6): undefined reference to `giterr_set_str'
          /usr/bin/ld: /builddir/cargo-0.33.0/target/release/deps/libgit2-197c7c3d8bde32da.rlib(git2-197c7c3d8bde32da.git2.dj0qflu2-cgu.5.rcgu.o): in function `git2::transport::set_err':
          git2.dj0qflu2-cgu.5:(.text._ZN4git29transport7set_err17h63962445c1177113E+0x17e): undefined reference to `giterr_set_str'
          /usr/bin/ld: /builddir/cargo-0.33.0/target/release/deps/libgit2-197c7c3d8bde32da.rlib(git2-197c7c3d8bde32da.git2.dj0qflu2-cgu.5.rcgu.o): in function `<git2::buf::Buf as core::ops::drop::Drop>::drop':
          git2.dj0qflu2-cgu.5:(.text._ZN56_$LT$git2..buf..Buf$u20$as$u20$core..ops..drop..Drop$GT$4drop17h618a9504daa57525E+0x2): undefined reference to `git_buf_free'
          /usr/bin/ld: /builddir/cargo-0.33.0/target/release/deps/libgit2-197c7c3d8bde32da.rlib(git2-197c7c3d8bde32da.git2.dj0qflu2-cgu.7.rcgu.o): in function `core::ptr::real_drop_in_place':
          git2.dj0qflu2-cgu.7:(.text._ZN4core3ptr18real_drop_in_place17h1a0b7585d37073a2E+0x2): undefined reference to `git_buf_free'
          /usr/bin/ld: /builddir/cargo-0.33.0/target/release/deps/libgit2-197c7c3d8bde32da.rlib(git2-197c7c3d8bde32da.git2.dj0qflu2-cgu.7.rcgu.o): in function `git2::object::Object::short_id':
          git2.dj0qflu2-cgu.7:(.text._ZN4git26object6Object8short_id17hf6ddbe00ab8ba01dE+0xf0): undefined reference to `git_buf_free'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `cargo`.

To learn more, run the command again with --verbose.
=> ERROR: cargo-0.33.0_2: do_build: './cargo build --release' exited with 101
=> ERROR:   in do_build() at srcpkgs/cargo/template:75

The error isn't even in Cargo itself but libgit2-sys which is fetched by it, there is no easy way around it, we can't simply patch it with the normal xbps-src.

There is only one thing we can do, mess with cargo, a more convoluted way than just dropping a patch into srcpkgs/pkg/patches and be done with it.

First we fork the libgit2-sys repo into our namespace and adapt it.

commit 23008957fec7a9479f27aa60e60c0614bf039137
Author: maxice8 <thinkabit.ukim@gmail.com>
Date:   Tue Feb 12 16:17:26 2019 -0200

    libgit2-0.28 api compat

diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs
index b1c4bdf..c6e7824 100644
--- a/libgit2-sys/lib.rs
+++ b/libgit2-sys/lib.rs
@@ -190,37 +190,37 @@ git_enum! {
 
 git_enum! {
     pub enum git_error_t {
-        GITERR_NONE = 0,
-        GITERR_NOMEMORY,
-        GITERR_OS,
-        GITERR_INVALID,
-        GITERR_REFERENCE,
-        GITERR_ZLIB,
-        GITERR_REPOSITORY,
-        GITERR_CONFIG,
-        GITERR_REGEX,
-        GITERR_ODB,
-        GITERR_INDEX,
-        GITERR_OBJECT,
-        GITERR_NET,
-        GITERR_TAG,
-        GITERR_TREE,
-        GITERR_INDEXER,
-        GITERR_SSL,
-        GITERR_SUBMODULE,
-        GITERR_THREAD,
-        GITERR_STASH,
-        GITERR_CHECKOUT,
-        GITERR_FETCHHEAD,
-        GITERR_MERGE,
-        GITERR_SSH,
-        GITERR_FILTER,
-        GITERR_REVERT,
-        GITERR_CALLBACK,
-        GITERR_CHERRYPICK,
-        GITERR_DESCRIBE,
-        GITERR_REBASE,
-        GITERR_FILESYSTEM,
+        GIT_ERROR_NONE = 0,
+        GIT_ERROR_NOMEMORY,
+        GIT_ERROR_OS,
+        GIT_ERROR_INVALID,
+        GIT_ERROR_REFERENCE,
+        GIT_ERROR_ZLIB,
+        GIT_ERROR_REPOSITORY,
+        GIT_ERROR_CONFIG,
+        GIT_ERROR_REGEX,
+        GIT_ERROR_ODB,
+        GIT_ERROR_INDEX,
+        GIT_ERROR_OBJECT,
+        GIT_ERROR_NET,
+        GIT_ERROR_TAG,
+        GIT_ERROR_TREE,
+        GIT_ERROR_INDEXER,
+        GIT_ERROR_SSL,
+        GIT_ERROR_SUBMODULE,
+        GIT_ERROR_THREAD,
+        GIT_ERROR_STASH,
+        GIT_ERROR_CHECKOUT,
+        GIT_ERROR_FETCHHEAD,
+        GIT_ERROR_MERGE,
+        GIT_ERROR_SSH,
+        GIT_ERROR_FILTER,
+        GIT_ERROR_REVERT,
+        GIT_ERROR_CALLBACK,
+        GIT_ERROR_CHERRYPICK,
+        GIT_ERROR_DESCRIBE,
+        GIT_ERROR_REBASE,
+        GIT_ERROR_FILESYSTEM,
     }
 }
 
@@ -612,16 +612,16 @@ git_enum! {
 
 git_enum! {
     pub enum git_otype: c_int {
-        GIT_OBJ_ANY = -2,
-        GIT_OBJ_BAD = -1,
-        GIT_OBJ__EXT1 = 0,
-        GIT_OBJ_COMMIT = 1,
-        GIT_OBJ_TREE = 2,
-        GIT_OBJ_BLOB = 3,
-        GIT_OBJ_TAG = 4,
-        GIT_OBJ__EXT2 = 5,
-        GIT_OBJ_OFS_DELTA = 6,
-        GIT_OBJ_REF_DELTA = 7,
+        GIT_OBJECT_ANY = -2,
+        GIT_OBJECT_BAD = -1,
+        GIT_OBJECT__EXT1 = 0,
+        GIT_OBJECT_COMMIT = 1,
+        GIT_OBJECT_TREE = 2,
+        GIT_OBJECT_BLOB = 3,
+        GIT_OBJECT_TAG = 4,
+        GIT_OBJECT__EXT2 = 5,
+        GIT_OBJECT_OFS_DELTA = 6,
+        GIT_OBJECT_REF_DELTA = 7,
     }
 }
 
@@ -714,29 +714,29 @@ pub type git_index_matched_path_cb = extern fn(*const c_char, *const c_char,
 
 git_enum! {
     pub enum git_idxentry_extended_flag_t {
-        GIT_IDXENTRY_INTENT_TO_ADD     = 1 << 13,
-        GIT_IDXENTRY_SKIP_WORKTREE     = 1 << 14,
-        GIT_IDXENTRY_EXTENDED2         = 1 << 15,
-
-        GIT_IDXENTRY_UPDATE            = 1 << 0,
-        GIT_IDXENTRY_REMOVE            = 1 << 1,
-        GIT_IDXENTRY_UPTODATE          = 1 << 2,
-        GIT_IDXENTRY_ADDED             = 1 << 3,
-
-        GIT_IDXENTRY_HASHED            = 1 << 4,
-        GIT_IDXENTRY_UNHASHED          = 1 << 5,
-        GIT_IDXENTRY_WT_REMOVE         = 1 << 6,
-        GIT_IDXENTRY_CONFLICTED        = 1 << 7,
-
-        GIT_IDXENTRY_UNPACKED          = 1 << 8,
-        GIT_IDXENTRY_NEW_SKIP_WORKTREE = 1 << 9,
+        GIT_INDEX_ENTRY_INTENT_TO_ADD     = 1 << 13,
+        GIT_INDEX_ENTRY_SKIP_WORKTREE     = 1 << 14,
+        GIT_INDEX_ENTRY_EXTENDED2         = 1 << 15,
+
+        GIT_INDEX_ENTRY_UPDATE            = 1 << 0,
+        GIT_INDEX_ENTRY_REMOVE            = 1 << 1,
+        GIT_INDEX_ENTRY_UPTODATE          = 1 << 2,
+        GIT_INDEX_ENTRY_ADDED             = 1 << 3,
+
+        GIT_INDEX_ENTRY_HASHED            = 1 << 4,
+        GIT_INDEX_ENTRY_UNHASHED          = 1 << 5,
+        GIT_INDEX_ENTRY_WT_REMOVE         = 1 << 6,
+        GIT_INDEX_ENTRY_CONFLICTED        = 1 << 7,
+
+        GIT_INDEX_ENTRY_UNPACKED          = 1 << 8,
+        GIT_INDEX_ENTRY_NEW_SKIP_WORKTREE = 1 << 9,
     }
 }
 
 git_enum! {
     pub enum git_indxentry_flag_t {
-        GIT_IDXENTRY_EXTENDED = 0x4000,
-        GIT_IDXENTRY_VALID    = 0x8000,
+        GIT_INDEX_ENTRY_EXTENDED = 0x4000,
+        GIT_INDEX_ENTRY_VALID    = 0x8000,
     }
 }
 
@@ -757,9 +757,9 @@ pub struct git_index_entry {
     pub path: *const c_char,
 }
 
-pub const GIT_IDXENTRY_NAMEMASK: u16 = 0xfff;
-pub const GIT_IDXENTRY_STAGEMASK: u16 = 0x3000;
-pub const GIT_IDXENTRY_STAGESHIFT: u16 = 12;
+pub const GIT_INDEX_ENTRY_NAMEMASK: u16 = 0xfff;
+pub const GIT_INDEX_ENTRY_STAGEMASK: u16 = 0x3000;
+pub const GIT_INDEX_ENTRY_STAGESHIFT: u16 = 12;
 
 #[repr(C)]
 #[derive(Copy, Clone, Eq, PartialEq)]
@@ -1719,10 +1719,10 @@ extern {
     pub fn git_oid_streq(id: *const git_oid, str: *const c_char) -> c_int;
     pub fn git_oid_iszero(id: *const git_oid) -> c_int;
 
-    // giterr
-    pub fn giterr_last() -> *const git_error;
-    pub fn giterr_clear();
-    pub fn giterr_set_str(error_class: c_int, string: *const c_char);
+    // git_error
+    pub fn git_error_last() -> *const git_error;
+    pub fn git_error_clear();
+    pub fn git_error_set_str(error_class: c_int, string: *const c_char);
 
     // remote
     pub fn git_remote_create(out: *mut *mut git_remote,
@@ -2120,7 +2120,7 @@ extern {
                                  bld: *mut git_treebuilder) -> c_int;
 
     // buf
-    pub fn git_buf_free(buffer: *mut git_buf);
+    pub fn git_buf_dispose(buffer: *mut git_buf);
     pub fn git_buf_grow(buffer: *mut git_buf, target_size: size_t) -> c_int;
     pub fn git_buf_set(buffer: *mut git_buf, data: *const c_void,
                        datalen: size_t) -> c_int;
diff --git a/src/buf.rs b/src/buf.rs
index 78e958e..9500443 100644
--- a/src/buf.rs
+++ b/src/buf.rs
@@ -68,6 +68,6 @@ impl Binding for Buf {
 
 impl Drop for Buf {
     fn drop(&mut self) {
-        unsafe { raw::git_buf_free(&mut self.raw) }
+        unsafe { raw::git_buf_dispose(&mut self.raw) }
     }
 }
diff --git a/src/call.rs b/src/call.rs
index 3367275..701df5b 100644
--- a/src/call.rs
+++ b/src/call.rs
@@ -113,11 +113,11 @@ mod impls {
     impl Convert<raw::git_otype> for ObjectType {
         fn convert(&self) -> raw::git_otype {
             match *self {
-                ObjectType::Any => raw::GIT_OBJ_ANY,
-                ObjectType::Commit => raw::GIT_OBJ_COMMIT,
-                ObjectType::Tree => raw::GIT_OBJ_TREE,
-                ObjectType::Blob => raw::GIT_OBJ_BLOB,
-                ObjectType::Tag => raw::GIT_OBJ_TAG,
+                ObjectType::Any => raw::GIT_OBJECT_ANY,
+                ObjectType::Commit => raw::GIT_OBJECT_COMMIT,
+                ObjectType::Tree => raw::GIT_OBJECT_TREE,
+                ObjectType::Blob => raw::GIT_OBJECT_BLOB,
+                ObjectType::Tag => raw::GIT_OBJECT_TAG,
             }
         }
     }
diff --git a/src/error.rs b/src/error.rs
index 1e92b23..e342d6c 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -22,7 +22,7 @@ impl Error {
     /// call. This code will later be returned from the `code` function.
     ///
     /// Historically this function returned `Some` or `None` based on the return
-    /// value of `giterr_last` but nowadays it always returns `Some` so it's
+    /// value of `git_error_last` but nowadays it always returns `Some` so it's
     /// safe to unwrap the return value. This API will change in the next major
     /// version.
     pub fn last_error(code: c_int) -> Option<Error> {
@@ -30,20 +30,20 @@ impl Error {
         unsafe {
             // Note that whenever libgit2 returns an error any negative value
             // indicates that an error happened. Auxiliary information is
-            // *usually* in `giterr_last` but unfortunately that's not always
+            // *usually* in `git_error_last` but unfortunately that's not always
             // the case. Sometimes a negative error code is returned from
-            // libgit2 *without* calling `giterr_set` internally to configure
+            // libgit2 *without* calling `git_error_set` internally to configure
             // the error.
             //
             // To handle this case and hopefully provide better error messages
-            // on our end we unconditionally call `giterr_clear` when we're done
+            // on our end we unconditionally call `git_error_clear` when we're done
             // with an error. This is an attempt to clear it as aggressively as
             // possible when we can to ensure that error information from one
             // api invocation doesn't leak over to the next api invocation.
             //
-            // Additionally if `giterr_last` returns null then we returned a
+            // Additionally if `git_error_last` returns null then we returned a
             // canned error out.
-            let ptr = raw::giterr_last();
+            let ptr = raw::git_error_last();
             let err = if ptr.is_null() {
                 let mut error = Error::from_str("an unknown git error occurred");
                 error.code = code;
@@ -51,7 +51,7 @@ impl Error {
             } else {
                 Error::from_raw(code, ptr)
             };
-            raw::giterr_clear();
+            raw::git_error_clear();
             Some(err)
         }
     }
@@ -65,11 +65,11 @@ impl Error {
     /// Creates a new error from the given string as the error.
     ///
     /// The error returned will have the code `GIT_ERROR` and the class
-    /// `GITERR_NONE`.
+    /// `GIT_ERROR_NONE`.
     pub fn from_str(s: &str) -> Error {
         Error {
             code: raw::GIT_ERROR as c_int,
-            klass: raw::GITERR_NONE as c_int,
+            klass: raw::GIT_ERROR_NONE as c_int,
             message: s.to_string(),
         }
     }
@@ -118,37 +118,37 @@ impl Error {
     /// typically not directly actionable.
     pub fn class(&self) -> ErrorClass {
         match self.raw_class() {
-            raw::GITERR_NONE => super::ErrorClass::None,
-            raw::GITERR_NOMEMORY => super::ErrorClass::NoMemory,
-            raw::GITERR_OS => super::ErrorClass::Os,
-            raw::GITERR_INVALID => super::ErrorClass::Invalid,
-            raw::GITERR_REFERENCE => super::ErrorClass::Reference,
-            raw::GITERR_ZLIB => super::ErrorClass::Zlib,
-            raw::GITERR_REPOSITORY => super::ErrorClass::Repository,
-            raw::GITERR_CONFIG => super::ErrorClass::Config,
-            raw::GITERR_REGEX => super::ErrorClass::Regex,
-            raw::GITERR_ODB => super::ErrorClass::Odb,
-            raw::GITERR_INDEX => super::ErrorClass::Index,
-            raw::GITERR_OBJECT => super::ErrorClass::Object,
-            raw::GITERR_NET => super::ErrorClass::Net,
-            raw::GITERR_TAG => super::ErrorClass::Tag,
-            raw::GITERR_TREE => super::ErrorClass::Tree,
-            raw::GITERR_INDEXER => super::ErrorClass::Indexer,
-            raw::GITERR_SSL => super::ErrorClass::Ssl,
-            raw::GITERR_SUBMODULE => super::ErrorClass::Submodule,
-            raw::GITERR_THREAD => super::ErrorClass::Thread,
-            raw::GITERR_STASH => super::ErrorClass::Stash,
-            raw::GITERR_CHECKOUT => super::ErrorClass::Checkout,
-            raw::GITERR_FETCHHEAD => super::ErrorClass::FetchHead,
-            raw::GITERR_MERGE => super::ErrorClass::Merge,
-            raw::GITERR_SSH => super::ErrorClass::Ssh,
-            raw::GITERR_FILTER => super::ErrorClass::Filter,
-            raw::GITERR_REVERT => super::ErrorClass::Revert,
-            raw::GITERR_CALLBACK => super::ErrorClass::Callback,
-            raw::GITERR_CHERRYPICK => super::ErrorClass::CherryPick,
-            raw::GITERR_DESCRIBE => super::ErrorClass::Describe,
-            raw::GITERR_REBASE => super::ErrorClass::Rebase,
-            raw::GITERR_FILESYSTEM => super::ErrorClass::Filesystem,
+            raw::GIT_ERROR_NONE => super::ErrorClass::None,
+            raw::GIT_ERROR_NOMEMORY => super::ErrorClass::NoMemory,
+            raw::GIT_ERROR_OS => super::ErrorClass::Os,
+            raw::GIT_ERROR_INVALID => super::ErrorClass::Invalid,
+            raw::GIT_ERROR_REFERENCE => super::ErrorClass::Reference,
+            raw::GIT_ERROR_ZLIB => super::ErrorClass::Zlib,
+            raw::GIT_ERROR_REPOSITORY => super::ErrorClass::Repository,
+            raw::GIT_ERROR_CONFIG => super::ErrorClass::Config,
+            raw::GIT_ERROR_REGEX => super::ErrorClass::Regex,
+            raw::GIT_ERROR_ODB => super::ErrorClass::Odb,
+            raw::GIT_ERROR_INDEX => super::ErrorClass::Index,
+            raw::GIT_ERROR_OBJECT => super::ErrorClass::Object,
+            raw::GIT_ERROR_NET => super::ErrorClass::Net,
+            raw::GIT_ERROR_TAG => super::ErrorClass::Tag,
+            raw::GIT_ERROR_TREE => super::ErrorClass::Tree,
+            raw::GIT_ERROR_INDEXER => super::ErrorClass::Indexer,
+            raw::GIT_ERROR_SSL => super::ErrorClass::Ssl,
+            raw::GIT_ERROR_SUBMODULE => super::ErrorClass::Submodule,
+            raw::GIT_ERROR_THREAD => super::ErrorClass::Thread,
+            raw::GIT_ERROR_STASH => super::ErrorClass::Stash,
+            raw::GIT_ERROR_CHECKOUT => super::ErrorClass::Checkout,
+            raw::GIT_ERROR_FETCHHEAD => super::ErrorClass::FetchHead,
+            raw::GIT_ERROR_MERGE => super::ErrorClass::Merge,
+            raw::GIT_ERROR_SSH => super::ErrorClass::Ssh,
+            raw::GIT_ERROR_FILTER => super::ErrorClass::Filter,
+            raw::GIT_ERROR_REVERT => super::ErrorClass::Revert,
+            raw::GIT_ERROR_CALLBACK => super::ErrorClass::Callback,
+            raw::GIT_ERROR_CHERRYPICK => super::ErrorClass::CherryPick,
+            raw::GIT_ERROR_DESCRIBE => super::ErrorClass::Describe,
+            raw::GIT_ERROR_REBASE => super::ErrorClass::Rebase,
+            raw::GIT_ERROR_FILESYSTEM => super::ErrorClass::Filesystem,
             _ => super::ErrorClass::None,
         }
     }
@@ -194,41 +194,41 @@ impl Error {
         macro_rules! check( ($($e:ident,)*) => (
             $(if self.klass == raw::$e as c_int { raw::$e }) else *
             else {
-                raw::GITERR_NONE
+                raw::GIT_ERROR_NONE
             }
         ) );
         check!(
-            GITERR_NONE,
-            GITERR_NOMEMORY,
-            GITERR_OS,
-            GITERR_INVALID,
-            GITERR_REFERENCE,
-            GITERR_ZLIB,
-            GITERR_REPOSITORY,
-            GITERR_CONFIG,
-            GITERR_REGEX,
-            GITERR_ODB,
-            GITERR_INDEX,
-            GITERR_OBJECT,
-            GITERR_NET,
-            GITERR_TAG,
-            GITERR_TREE,
-            GITERR_INDEXER,
-            GITERR_SSL,
-            GITERR_SUBMODULE,
-            GITERR_THREAD,
-            GITERR_STASH,
-            GITERR_CHECKOUT,
-            GITERR_FETCHHEAD,
-            GITERR_MERGE,
-            GITERR_SSH,
-            GITERR_FILTER,
-            GITERR_REVERT,
-            GITERR_CALLBACK,
-            GITERR_CHERRYPICK,
-            GITERR_DESCRIBE,
-            GITERR_REBASE,
-            GITERR_FILESYSTEM,
+            GIT_ERROR_NONE,
+            GIT_ERROR_NOMEMORY,
+            GIT_ERROR_OS,
+            GIT_ERROR_INVALID,
+            GIT_ERROR_REFERENCE,
+            GIT_ERROR_ZLIB,
+            GIT_ERROR_REPOSITORY,
+            GIT_ERROR_CONFIG,
+            GIT_ERROR_REGEX,
+            GIT_ERROR_ODB,
+            GIT_ERROR_INDEX,
+            GIT_ERROR_OBJECT,
+            GIT_ERROR_NET,
+            GIT_ERROR_TAG,
+            GIT_ERROR_TREE,
+            GIT_ERROR_INDEXER,
+            GIT_ERROR_SSL,
+            GIT_ERROR_SUBMODULE,
+            GIT_ERROR_THREAD,
+            GIT_ERROR_STASH,
+            GIT_ERROR_CHECKOUT,
+            GIT_ERROR_FETCHHEAD,
+            GIT_ERROR_MERGE,
+            GIT_ERROR_SSH,
+            GIT_ERROR_FILTER,
+            GIT_ERROR_REVERT,
+            GIT_ERROR_CALLBACK,
+            GIT_ERROR_CHERRYPICK,
+            GIT_ERROR_DESCRIBE,
+            GIT_ERROR_REBASE,
+            GIT_ERROR_FILESYSTEM,
         )
     }
 
diff --git a/src/index.rs b/src/index.rs
index 1071db3..9c618c7 100644
--- a/src/index.rs
+++ b/src/index.rs
@@ -112,12 +112,12 @@ impl Index {
         // libgit2 encodes the length of the path in the lower bits of the
         // `flags` entry, so mask those out and recalculate here to ensure we
         // don't corrupt anything.
-        let mut flags = entry.flags & !raw::GIT_IDXENTRY_NAMEMASK;
+        let mut flags = entry.flags & !raw::GIT_INDEX_ENTRY_NAMEMASK;
 
-        if entry.path.len() < raw::GIT_IDXENTRY_NAMEMASK as usize {
+        if entry.path.len() < raw::GIT_INDEX_ENTRY_NAMEMASK as usize {
             flags |= entry.path.len() as u16;
         } else {
-            flags |= raw::GIT_IDXENTRY_NAMEMASK;
+            flags |= raw::GIT_INDEX_ENTRY_NAMEMASK;
         }
 
         unsafe {
@@ -169,12 +169,12 @@ impl Index {
         // libgit2 encodes the length of the path in the lower bits of the
         // `flags` entry, so mask those out and recalculate here to ensure we
         // don't corrupt anything.
-        let mut flags = entry.flags & !raw::GIT_IDXENTRY_NAMEMASK;
+        let mut flags = entry.flags & !raw::GIT_INDEX_ENTRY_NAMEMASK;
 
-        if entry.path.len() < raw::GIT_IDXENTRY_NAMEMASK as usize {
+        if entry.path.len() < raw::GIT_INDEX_ENTRY_NAMEMASK as usize {
             flags |= entry.path.len() as u16;
         } else {
-            flags |= raw::GIT_IDXENTRY_NAMEMASK;
+            flags |= raw::GIT_INDEX_ENTRY_NAMEMASK;
         }
 
         unsafe {
@@ -608,8 +608,8 @@ impl Binding for IndexEntry {
         // libgit2 encodes the length of the path in the lower bits of `flags`,
         // but if the length exceeds the number of bits then the path is
         // nul-terminated.
-        let mut pathlen = (flags & raw::GIT_IDXENTRY_NAMEMASK) as usize;
-        if pathlen == raw::GIT_IDXENTRY_NAMEMASK as usize {
+        let mut pathlen = (flags & raw::GIT_INDEX_ENTRY_NAMEMASK) as usize;
+        if pathlen == raw::GIT_INDEX_ENTRY_NAMEMASK as usize {
             pathlen = CStr::from_ptr(path).to_bytes().len();
         }
 
diff --git a/src/lib.rs b/src/lib.rs
index 7960bd8..09ce3d0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -443,9 +443,9 @@ bitflags! {
     /// Flags for the `flags` field of an IndexEntry.
     pub struct IndexEntryFlag: u16 {
         /// Set when the `extended_flags` field is valid.
-        const EXTENDED = raw::GIT_IDXENTRY_EXTENDED as u16;
+        const EXTENDED = raw::GIT_INDEX_ENTRY_EXTENDED as u16;
         /// "Assume valid" flag
-        const VALID = raw::GIT_IDXENTRY_VALID as u16;
+        const VALID = raw::GIT_INDEX_ENTRY_VALID as u16;
     }
 }
 
@@ -458,34 +458,34 @@ bitflags! {
     /// Flags for the `extended_flags` field of an IndexEntry.
     pub struct IndexEntryExtendedFlag: u16 {
         /// An "intent to add" entry from "git add -N"
-        const INTENT_TO_ADD = raw::GIT_IDXENTRY_INTENT_TO_ADD as u16;
+        const INTENT_TO_ADD = raw::GIT_INDEX_ENTRY_INTENT_TO_ADD as u16;
         /// Skip the associated worktree file, for sparse checkouts
-        const SKIP_WORKTREE = raw::GIT_IDXENTRY_SKIP_WORKTREE as u16;
+        const SKIP_WORKTREE = raw::GIT_INDEX_ENTRY_SKIP_WORKTREE as u16;
         /// Reserved for a future on-disk extended flag
-        const EXTENDED2 = raw::GIT_IDXENTRY_EXTENDED2 as u16;
+        const EXTENDED2 = raw::GIT_INDEX_ENTRY_EXTENDED2 as u16;
 
         #[allow(missing_docs)]
-        const UPDATE = raw::GIT_IDXENTRY_UPDATE as u16;
+        const UPDATE = raw::GIT_INDEX_ENTRY_UPDATE as u16;
         #[allow(missing_docs)]
-        const REMOVE = raw::GIT_IDXENTRY_REMOVE as u16;
+        const REMOVE = raw::GIT_INDEX_ENTRY_REMOVE as u16;
         #[allow(missing_docs)]
-        const UPTODATE = raw::GIT_IDXENTRY_UPTODATE as u16;
+        const UPTODATE = raw::GIT_INDEX_ENTRY_UPTODATE as u16;
         #[allow(missing_docs)]
-        const ADDED = raw::GIT_IDXENTRY_ADDED as u16;
+        const ADDED = raw::GIT_INDEX_ENTRY_ADDED as u16;
 
         #[allow(missing_docs)]
-        const HASHED = raw::GIT_IDXENTRY_HASHED as u16;
+        const HASHED = raw::GIT_INDEX_ENTRY_HASHED as u16;
         #[allow(missing_docs)]
-        const UNHASHED = raw::GIT_IDXENTRY_UNHASHED as u16;
+        const UNHASHED = raw::GIT_INDEX_ENTRY_UNHASHED as u16;
         #[allow(missing_docs)]
-        const WT_REMOVE = raw::GIT_IDXENTRY_WT_REMOVE as u16;
+        const WT_REMOVE = raw::GIT_INDEX_ENTRY_WT_REMOVE as u16;
         #[allow(missing_docs)]
-        const CONFLICTED = raw::GIT_IDXENTRY_CONFLICTED as u16;
+        const CONFLICTED = raw::GIT_INDEX_ENTRY_CONFLICTED as u16;
 
         #[allow(missing_docs)]
-        const UNPACKED = raw::GIT_IDXENTRY_UNPACKED as u16;
+        const UNPACKED = raw::GIT_INDEX_ENTRY_UNPACKED as u16;
         #[allow(missing_docs)]
-        const NEW_SKIP_WORKTREE = raw::GIT_IDXENTRY_NEW_SKIP_WORKTREE as u16;
+        const NEW_SKIP_WORKTREE = raw::GIT_INDEX_ENTRY_NEW_SKIP_WORKTREE as u16;
     }
 }
 
@@ -841,11 +841,11 @@ impl ObjectType {
     /// Convert a raw git_otype to an ObjectType
     pub fn from_raw(raw: raw::git_otype) -> Option<ObjectType> {
         match raw {
-            raw::GIT_OBJ_ANY => Some(ObjectType::Any),
-            raw::GIT_OBJ_COMMIT => Some(ObjectType::Commit),
-            raw::GIT_OBJ_TREE => Some(ObjectType::Tree),
-            raw::GIT_OBJ_BLOB => Some(ObjectType::Blob),
-            raw::GIT_OBJ_TAG => Some(ObjectType::Tag),
+            raw::GIT_OBJECT_ANY => Some(ObjectType::Any),
+            raw::GIT_OBJECT_COMMIT => Some(ObjectType::Commit),
+            raw::GIT_OBJECT_TREE => Some(ObjectType::Tree),
+            raw::GIT_OBJECT_BLOB => Some(ObjectType::Blob),
+            raw::GIT_OBJECT_TAG => Some(ObjectType::Tag),
             _ => None,
         }
     }
diff --git a/src/remote_callbacks.rs b/src/remote_callbacks.rs
index 562d3a2..72e61a4 100644
--- a/src/remote_callbacks.rs
+++ b/src/remote_callbacks.rs
@@ -280,7 +280,7 @@ extern fn credentials_cb(ret: *mut *mut raw::git_cred,
 
             callback(url, username_from_url, cred_type).map_err(|e| {
                 let s = CString::new(e.to_string()).unwrap();
-                raw::giterr_set_str(e.raw_code() as c_int, s.as_ptr());
+                raw::git_error_set_str(e.raw_code() as c_int, s.as_ptr());
                 e.raw_code() as c_int
             })
         });
diff --git a/src/transport.rs b/src/transport.rs
index d34db9f..56cef7a 100644
--- a/src/transport.rs
+++ b/src/transport.rs
@@ -314,7 +314,7 @@ extern fn stream_write(stream: *mut raw::git_smart_subtransport_stream,
 
 unsafe fn set_err(e: &io::Error) {
     let s = CString::new(e.to_string()).unwrap();
-    raw::giterr_set_str(raw::GITERR_NET as c_int, s.as_ptr())
+    raw::git_error_set_str(raw::GIT_ERROR_NET as c_int, s.as_ptr())
 }
 
 // callback used by smart transports to free a `SmartSubtransportStream`

Kind of an expected size since it is a wrapper, you can see it touches other areas that other packages don't. Like GIT_OBJ -> GIT_OBJECT and GIT_IDXENTRY -> GIT_INDEX_ENTRY.

Now that we have created a new repo let's patch it in the cargo package Cargo.toml file.

diff --git a/Cargo.toml b/Cargo.toml
index d2d48ff..8647870 100644
--- Cargo.toml
+++ Cargo.toml
@@ -107,3 +107,8 @@ doc = false
 [features]
 vendored-openssl = ['openssl/vendored']
 pretty-env-logger = ['pretty_env_logger']
+
+[patch.crates-io]
+libgit2-sys = {git = 'https://github.com/maxice8/git2-rs', rev = '23008957fec7a9479f27aa60e60c0614bf039137'}
+git2 = {git = 'https://github.com/maxice8/git2-rs', rev = '23008957fec7a9479f27aa60e60c0614bf039137'}
+git2-curl = {git = 'https://github.com/maxice8/git2-rs', rev = '23008957fec7a9479f27aa60e60c0614bf039137'}

This sucks, we had to make a new repo to get a few patches in to change a few dependencies into the new libgit2 API.

$ xbps-src pkg cargo
error[E0531]: cannot find unit struct/variant or constant `GIT_OBJ_TAG` in module `raw`
   --> /tmp/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.7.5/src/lib.rs:846:18
    |
846 |             raw::GIT_OBJ_TAG => Some(ObjectType::Tag),
    |                  ^^^^^^^^^^^ did you mean `GIT_OBJECT_TAG`?

Oh, it still fails, everything that uses git2 needs to be patched as well, oh well the rust people can figure this out and we can wait.

grv

Ok, this one is not in rust like cargo, cargo-outdated and git-series, so it should be pretty safe to update, right ?

$ xbps-src pkg grv
WORK=/tmp/go-build359986509
mkdir -p $WORK/b065/
cd /builddir/grv/_build-grv-xbps/src/github.com/rgburke/grv/cmd/grv/vendor/gopkg.in/libgit2/git2go.v27
pkg-config --cflags -- libgit2
pkg-config --libs -- libgit2
CGO_LDFLAGS='"-lgit2"' /usr/lib/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b065/ -importpath github.com/rgburke/grv/cmd/grv/vendor/gopkg.in/libgit2/git2go.v27 -- -I $WORK/b065/ -mtune=generic -O2 -pipe ./blame.go ./blob.go ./branch.go ./checkout.go ./cherrypick.go ./clone.go ./commit.go ./config.go ./credentials.go ./describe.go ./diff.go ./features.go ./git.go ./git_dynamic.go ./graph.go ./handles.go ./ignore.go ./index.go ./merge.go ./note.go ./object.go ./odb.go ./packbuilder.go ./patch.go ./rebase.go ./refdb.go ./reference.go ./remote.go ./repository.go ./reset.go ./revparse.go ./settings.go ./signature.go ./stash.go ./status.go ./submodule.go ./tag.go ./tree.go ./walk.go
# github.com/rgburke/grv/cmd/grv/vendor/gopkg.in/libgit2/git2go.v27
_build-grv-xbps/src/github.com/rgburke/grv/cmd/grv/vendor/gopkg.in/libgit2/git2go.v27/git_dynamic.go:10:3: error: #error "Invalid libgit2 version; this git2go supports libgit2 v0.27"
 # error "Invalid libgit2 version; this git2go supports libgit2 v0.27"
   ^~~~~
=> ERROR: grv-0.3.1_3: do_build: 'go get -x -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}' exited with 2
=> ERROR:   in do_build() at common/build-style/go.sh:39

Ah nice, at least it fails with a good message, let's wait for upstream on that one.

Finishing

And that is all, we now wait for the hip languages to update their stuff so they can finally catch up with standard languages like C and C++.