Git.vala
[gitlive] / Git.vala
index ed4bc6d..18da46e 100644 (file)
--- a/Git.vala
+++ b/Git.vala
@@ -19,14 +19,24 @@ void main()
 
        Ggit.init();
        
+       var loop = new MainLoop();
+       
        var a = new GitLive.Repo("/home/alan/gitlive/gitlive");
+       
+       a.loadRemoteHeads.begin((obj,res) => {
+               a.loadRemoteHeads.end(res);
+               print("got results");
+               a.loadLocalBranches();
+               loop.quit();
+       });
+       loop.run();
        //a.mergeMasterIntoHead();
        //a.walkDiff();
        //return;
        //a.is_managed();
        //a.is_autocommit();
-       a.loadLocalBranches();
-       a.loadRemoteHeads();
+       
+
        //a.fetchAll();
        //
        /*
@@ -92,7 +102,8 @@ namespace  GitLive {
                                //var rhead = this.repo.revparse(br.get_upstream().get_name() ).get_id();
                            GLib.debug("got branch: H=%s name = %s upstream = %s oid = %s ", 
                                                br.is_head() ? "Y" : "n",
-                                               br.get_name(), br.get_upstream().get_name(), 
+                                               br.get_name(), 
+                                               br.get_upstream().get_name().substring(20), 
                                            br.get_target().to_string());
                                this.branches.add(br);
                                if (br.is_head()) {
@@ -285,7 +296,7 @@ namespace  GitLive {
         
                }
                
-               public void loadRemoteHeads(bool force = false)
+               public async  void loadRemoteHeads(bool force = false)
                {
                        
                        if (!force && this.remote_heads != null) {
@@ -296,8 +307,12 @@ namespace  GitLive {
                        this.remote_heads = r.list();
                        
                        foreach(var br in this.remote_heads) {
+                               if (!br.get_name().has_prefix("refs/heads/")) {
+                                       continue;
+                               }
+                               
                                GLib.debug("Remote: name=%s  oid=%s local_oid=%s is_local=%s",
-                                       br.get_name(),
+                                       br.get_name().substring(11),
                                        br.get_oid().to_string(),
                                        br.get_local_oid().to_string(),
                                        br.is_local() ? "Y" : "n"
@@ -305,8 +320,7 @@ namespace  GitLive {
                                        }
                        
                }
-               
-               
+                
                
                Ggit.Branch? getBranch(string remote_name, string remote_branch_name)
                {
@@ -370,7 +384,10 @@ namespace  GitLive {
                                                br == null ? "?": this.repo.revparse(br.get_name() ).get_id().to_string()
                                        );
                                        */
-                                       var loc_oid = this.repo.revparse(br.get_name() ).get_id();
+                                       //var loc_oid = this.repo.revparse(br.get_name() ).get_id();
+                                       
+                                       var loc_oid = br.get_target();
+                                       
                                        size_t ahead, behind;
                                        this.repo.get_ahead_behind(
                                                loc_oid,