[geany/geany-plugins] 4d3cde: git-changebar: Fix repository opening with libgit2 0.24.2

Colomban Wendling git-noreply at geany.org
Tue Nov 1 09:24:38 UTC 2016


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 01 Nov 2016 09:24:38 UTC
Commit:      4d3cded7b4168343c97f00d61c6203350c252bf3
             https://github.com/geany/geany-plugins/commit/4d3cded7b4168343c97f00d61c6203350c252bf3

Log Message:
-----------
git-changebar: Fix repository opening with libgit2 0.24.2

git_repository_open_ext() expects a directory, not a file.  Passing in
a file path used to work, but broke in the latest version.  Fix this by
explicitly passing the file's directory path instead, as we should.

Patch from @intact

Fixes #493.


Modified Paths:
--------------
    git-changebar/src/gcb-plugin.c

Modified: git-changebar/src/gcb-plugin.c
30 lines changed, 17 insertions(+), 13 deletions(-)
===================================================================
@@ -419,20 +419,24 @@ worker_thread (gpointer data)
         }
       }
     }
-    if (! repo && git_repository_open_ext (&repo, path, 0, NULL) == 0) {
-      if (git_repository_is_bare (repo)) {
-        git_repository_free (repo);
-        repo = NULL;
-      } else if (G_monitoring_enabled) {
-        /* we need to monitor HEAD, in case of e.g. branch switch (e.g.
-         * git checkout -b will switch the ref we need to watch) */
-        monitors[0] = monitor_repo_file (repo, "HEAD",
-                                         G_CALLBACK (on_git_repo_changed),
-                                         GINT_TO_POINTER (TRUE));
-        /* and of course the real ref (branch) for when changes get committed */
-        monitors[1] = monitor_head_ref (repo, G_CALLBACK (on_git_repo_changed),
-                                        GINT_TO_POINTER (FALSE));
+    if (! repo) {
+      gchar *dirname = g_path_get_dirname (path);
+      if (git_repository_open_ext (&repo, dirname, 0, NULL) == 0) {
+        if (git_repository_is_bare (repo)) {
+          git_repository_free (repo);
+          repo = NULL;
+        } else if (G_monitoring_enabled) {
+          /* we need to monitor HEAD, in case of e.g. branch switch (e.g.
+           * git checkout -b will switch the ref we need to watch) */
+          monitors[0] = monitor_repo_file (repo, "HEAD",
+                                           G_CALLBACK (on_git_repo_changed),
+                                           GINT_TO_POINTER (TRUE));
+          /* and of course the real ref (branch) for when changes get committed */
+          monitors[1] = monitor_head_ref (repo, G_CALLBACK (on_git_repo_changed),
+                                          GINT_TO_POINTER (FALSE));
+        }
       }
+      g_free(dirname);
     }
     
     buf_zero (&job->buf);



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list