GitRepo.vala
authorAlan Knowles <alan@roojs.com>
Wed, 20 Mar 2019 10:32:59 +0000 (18:32 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 20 Mar 2019 10:32:59 +0000 (18:32 +0800)
GitRepo.vala

index d216464..cdadaed 100644 (file)
@@ -958,25 +958,41 @@ public class GitRepo : Object
     
     public async void doUpdate()
     {
-       // update the branches..
-       this.loadBranches();
+       SourceFunc callback = GitRepo.get.callback;
+               GitRepo ret = null;
+               ThreadFunc<bool> run = () => {
+                       
+                       
+               // update the branches..
+                       this.loadBranches();
 
-               //GLib.debug("connecting '%s'", r.get_url());
-               string[] far = {}
-               foreach(var br in this.branches.values) {
-                       if (br.remote == "" || br.remoterev == br.lastrev) {
-                               continue;
+                       //GLib.debug("connecting '%s'", r.get_url());
+                       string[] far = {}
+                       foreach(var br in this.branches.values) {
+                               if (br.remote == "" || br.remoterev == br.lastrev) {
+                                       continue;
+                               }
+                               far +=  ("+refs/heads/" + br.name + ":refs/remotes/" + br.remote);
                        }
-                       far +=  ("+refs/heads/" + br.name + ":refs/remotes/" + br.remote);
-               }
-               if (far.length > 0) {
-               var r = this.repo.lookup_remote("origin");
-                       r.connect(Ggit.Direction.FETCH, new GitCallbacks, null, null);
-                       var options = new Ggit.FetchOptions();
-                       //options.set_remote_callbacks(this.callbacks);
-                   r.download(far, options);
-               }
-               repo.loadStatus();
+                       if (far.length > 0) {
+                               var r = this.repo.lookup_remote("origin");
+                               r.connect(Ggit.Direction.FETCH, new GitCallbacks, null, null);
+                               var options = new Ggit.FetchOptions();
+                               //options.set_remote_callbacks(this.callbacks);
+                               r.download(far, options);
+                       }
+                       repo.loadStatus();
+                       
+               
+                       Idle.add((owned) callback);
+               return true;
+                       
+               };
+               new Thread<bool>("thread-new-gitrepo", run);
+               yield;
+               return ret;
+       
+