geany-plugins icon indicating copy to clipboard operation
geany-plugins copied to clipboard

git-changebar fails to compile with libgit2-1.4.0

Open cjmayo opened this issue 3 years ago • 4 comments

gcb-plugin.c: In function ‘gcb_git_buf_grow’:
gcb-plugin.c:219:12: error: ‘git_buf’ has no member named ‘asize’; did you mean ‘size’?
  219 |   if (buf->asize == 0) {
      |            ^~~~~
      |            size
gcb-plugin.c: In function ‘buf_zero’:
gcb-plugin.c:237:10: error: ‘git_buf’ has no member named ‘asize’; did you mean ‘size’?
  237 |     buf->asize = 0;
      |          ^~~~~
      |          size

geany-plugins 1.38.0

cjmayo avatar Feb 18 '22 19:02 cjmayo

We are also seeing this on Arch Linux and it is blocking our upgrade to libgit2 1.4.1. A fix for this would be much appreciated! :)

dvzrv avatar Feb 18 '22 21:02 dvzrv

It appears that git_buf has undergone a major rewrite in https://github.com/libgit2/libgit2/pull/6078

The following fixes this for my build, but I admit that I have no clue what I am doing here and this could not be the way to fix this:

diff --git i/git-changebar/src/gcb-plugin.c w/git-changebar/src/gcb-plugin.c
index f8ce20cd..4488b22f 100644
--- i/git-changebar/src/gcb-plugin.c
+++ w/git-changebar/src/gcb-plugin.c
@@ -216,7 +216,7 @@ static int
 gcb_git_buf_grow (git_buf  *buf,
                   size_t    target_size)
 {
-  if (buf->asize == 0) {
+  if (buf->reserved == 0) {
     if (target_size == 0) {
       target_size = buf->size;
     }
@@ -234,7 +234,7 @@ buf_zero (git_buf *buf)
   if (buf) {
     buf->ptr = NULL;
     buf->size = 0;
-    buf->asize = 0;
+    buf->reserved = 0;
   }
 }
 

dvzrv avatar Feb 18 '22 22:02 dvzrv

It is going to be (literally) years before Debian stable or Ubuntu LTS get to libgit1.4.1 so I presume that the plugin maintainer will still want it to build against earlier libgit versions.

So when somebody makes a PR the code using new API should be #ifed based on what version is being built against and I expect configure should enable the right version.

elextr avatar Feb 18 '22 22:02 elextr

@dvzrv's approach is good. I added the necessary ifdefs in #1165.

However, as said in the PR, in the long term more code refactoring will be necessary as the whole git_buf object is now meant to be readonly and we use APIs to modify it but those APIs are already deprecated.

eht16 avatar Feb 20 '22 12:02 eht16