GitRepo.vala
authorAlan Knowles <alan@roojs.com>
Wed, 27 Sep 2017 06:31:18 +0000 (14:31 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 27 Sep 2017 06:31:18 +0000 (14:31 +0800)
GitRepo.vala

index a31935f..d69a112 100644 (file)
@@ -274,12 +274,13 @@ public class GitRepo : Object
         
     }
     
-    public delegate void GitAsyncCallback (string str);
-    public string pull_async(GitAsyncCallback cb) 
+    public delegate void GitAsyncCallback (GitRepo repo, string str);
+    public void pull_async(GitAsyncCallback cb) 
     {
     
         string[] cmd = { "pull" , "--no-edit" };
-        return this.git_async( cmd , cb);
+         this.git_async( cmd , cb);
+         
     
     }
     
@@ -352,11 +353,11 @@ public class GitRepo : Object
         return sp.output;
     }
        
-       
+   unowned GitAsyncCallback git_async_on_callback;
        public void  git_async( string[] args_in,   GitAsyncCallback cb ) throws Error, SpawnError
     {
         // convert arguments.
-        
+       this.git_async_on_callback = cb;
         string[]  args = { "git" };
         //args +=  "--git-dir";
         //args +=  this.gitdir;
@@ -392,9 +393,20 @@ public class GitRepo : Object
 
        // may throw error...
         var sp = new Spawn(cfg);
-        sp.run((err, output) => {
-               cb(output);
-        });
+               //sp.ref();
+        //this.ref();
+        sp.run(this.git_async_on_complete); 
          
     }
+    
+    void git_async_on_complete(int err, string output)
+    {
+               print("GOT %s\n", output);
+               this.git_async_on_callback(this, output);
+//             this.unref();   
+       //      sp.unref();             
+    
+    
+    }
+    
 }