From d108f660aa6f8e281a883fe1fb2b13de97717a4c Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 27 Sep 2017 14:31:18 +0800 Subject: [PATCH] GitRepo.vala --- GitRepo.vala | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/GitRepo.vala b/GitRepo.vala index a31935f3..d69a112a 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -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(); + + + } + } -- 2.39.2